class Frameio::Client

Attributes

token[R]

Public Class Methods

new(token) click to toggle source
# File lib/frameio/client.rb, line 8
def initialize(token)
  @token = token
end

Public Instance Methods

auth_headers() click to toggle source
# File lib/frameio/client.rb, line 40
def auth_headers
  { 
    Authorization: "Bearer #{access_token}"
  }
end
create(request_path, body:) click to toggle source
# File lib/frameio/client.rb, line 12
def create(request_path, body:)
  request(:post, request_path, body)
end
delete(request_path) click to toggle source
# File lib/frameio/client.rb, line 16
def delete(request_path)
  request(:delete, request_path)
end
get(request_path) click to toggle source
# File lib/frameio/client.rb, line 20
def get(request_path)
  request(:get, request_path)
end
to_ostruct(hash) click to toggle source
# 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: {}) click to toggle source
# 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:) click to toggle source
# File lib/frameio/client.rb, line 24
def update(request_path, body:)
  request(:put, request_path, body)
end

Private Instance Methods

access_token() click to toggle source
# File lib/frameio/client.rb, line 48
def access_token
  @token
end
base_url() click to toggle source
# File lib/frameio/client.rb, line 52
def base_url
  "https://api.frame.io/v2"
end
request(method, path, body: {}) click to toggle source
# File lib/frameio/client.rb, line 56
def request(method, path, body: {})
  if body.empty?
    HTTParty.send(method, "#{base_url}""#{path}", headers: auth_headers)
  else 
    HTTParty.send(method, "#{base_url}""#{path}", headers: auth_headers, body: body)
  end
end