Class: Frameio::Client
- Inherits:
-
Object
- Object
- Frameio::Client
- Includes:
- HTTParty
- Defined in:
- lib/frameio/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #auth_headers ⇒ Object
- #create(request_path, body:) ⇒ Object
- #delete(request_path) ⇒ Object
- #get(request_path) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #to_ostruct(hash) ⇒ Object
- #to_query_string(query_values: {}) ⇒ Object
- #update(request_path, body:) ⇒ Object
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/frameio/client.rb', line 8 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/frameio/client.rb', line 6 def token @token end |
Instance Method Details
#auth_headers ⇒ Object
40 41 42 43 44 |
# File 'lib/frameio/client.rb', line 40 def auth_headers { Authorization: "Bearer #{access_token}" } end |
#create(request_path, body:) ⇒ Object
12 13 14 |
# File 'lib/frameio/client.rb', line 12 def create(request_path, body:) request(:post, request_path, body) end |
#delete(request_path) ⇒ Object
16 17 18 |
# File 'lib/frameio/client.rb', line 16 def delete(request_path) request(:delete, request_path) end |
#get(request_path) ⇒ Object
20 21 22 |
# File 'lib/frameio/client.rb', line 20 def get(request_path) request(:get, request_path) end |
#to_ostruct(hash) ⇒ Object
34 35 36 37 38 |
# File 'lib/frameio/client.rb', line 34 def to_ostruct(hash) OpenStruct.new(hash.each_with_object({}) do |(key, val), memo| memo[key] = val.is_a?(Hash) ? to_ostruct(val) : val end) end |
#to_query_string(query_values: {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/frameio/client.rb', line 28 def to_query_string(query_values: {}) uri = Addressable::URI.new uri.query_values = query_values uri.query end |
#update(request_path, body:) ⇒ Object
24 25 26 |
# File 'lib/frameio/client.rb', line 24 def update(request_path, body:) request(:put, request_path, body) end |