Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ Layout/LineLength:
RSpec/SpecFilePathFormat:
Enabled: false

# Disable this rule for RSpec
RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

Style/Documentation:
Enabled: false
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ client = Boxr::Client.new('zX3UjFwNerOy5PSWc2WI8aJgMHtAjs8T',

# You can provide another parameter called as_user. Read about what that means here: https://developer.box.com/reference#as-user-1

# You can provide yet another parameter called identifier. This can be used, for example, to
# You can provide another parameter called identifier. This can be used, for example, to
# hold the id of the user associated with this Boxr client. When the callback is invoked this value
# will be provided.
```
Expand All @@ -115,6 +115,7 @@ initialize( access_token=ENV['BOX_DEVELOPER_TOKEN'],
jwt_public_key_id: ENV['JWT_PUBLIC_KEY_ID'],
identifier: nil,
as_user: nil,
proxy: nil,
&token_refresh_listener)
```

Expand All @@ -132,6 +133,14 @@ updated_file = client.create_shared_link_for_file(file, access: :open)
puts "Shared Link: #{updated_file.shared_link.url}"
```

### Using a proxy
You can provide a proxy to Boxr::Client.new by passing the proxy parameter.
```ruby
client = Boxr::Client.new(proxy: 'http://username:[email protected]:8080')
```
Boxr uses HTTPClient under the hood, so you can use all the features of HTTPClient's proxy support.
See https://www.rubydoc.info/gems/httpclient/HTTPClient#proxy=-instance_method for more details.

### NOTE: Using HTTP mocking libraries for testing
When using HTTP mocking libraries for testing, you may need to set Boxr::BOX_CLIENT to a fresh instance of HTTPClient in your test setup after loading the HTTP mocking library. For example, when using WebMock with RSpec you might could add the following to your RSpec configuration:
``` ruby
Expand Down Expand Up @@ -319,7 +328,9 @@ delete_comment(comment)
```
#### [Collaborations](https://developer.box.com/en/reference/resources/collaboration/)
```ruby
folder_collaborations(folder)
folder_collaborations(folder, fields: [], limit: DEFAULT_LIMIT, marker: nil)

file_collaborations(file, fields: [], limit: DEFAULT_LIMIT, marker: nil)

add_collaboration(folder, accessible_by, role, fields: [], notify: nil)

Expand Down
2 changes: 2 additions & 0 deletions lib/boxr/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def initialize(access_token = ENV['BOX_DEVELOPER_TOKEN'],
jwt_public_key_id: ENV['JWT_PUBLIC_KEY_ID'],
identifier: nil,
as_user: nil,
proxy: nil,
&token_refresh_listener)
@access_token = access_token
raise BoxrError.new(boxr_message: 'Access token cannot be nil') if @access_token.nil?
Expand All @@ -94,6 +95,7 @@ def initialize(access_token = ENV['BOX_DEVELOPER_TOKEN'],
@identifier = identifier
@as_user_id = ensure_id(as_user)
@token_refresh_listener = token_refresh_listener
BOX_CLIENT.proxy = proxy unless proxy.nil?
end

private
Expand Down
Loading