Class: UscreenAPI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/uscreen_api/client.rb

Constant Summary collapse

BASE_URL =
"https://www.uscreen.io/publisher_api/v1/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:) ⇒ Client

Returns a new instance of Client.



11
12
13
# File 'lib/uscreen_api/client.rb', line 11

def initialize(api_key:)
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/uscreen_api/client.rb', line 7

def api_key
  @api_key
end

Instance Method Details

#connectionObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/uscreen_api/client.rb', line 19

def connection
  @connection = Faraday.new(
    url: BASE_URL,
    headers: {
      "Content-Type": "application/json",
      Authorization: api_key
    }
  ) do |f|
    f.request(:json)
    f.response(:json)
  end
end

#customersObject



15
16
17
# File 'lib/uscreen_api/client.rb', line 15

def customers
  @customers ||= UscreenAPI::Customers.new(client: self)
end