Class: Omie::Client

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

Constant Summary collapse

BASE_URL =
"https://app.omie.com.br/api/v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_key: nil, app_secret: nil) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/omie/client.rb', line 13

def initialize(app_key: nil, app_secret: nil)
  @app_key = app_key || ENV.fetch("OMIE_APP_KEY")
  @app_secret = app_secret || ENV.fetch("OMIE_APP_SECRET")

  @conn = Faraday.new(BASE_URL) do |conn|
    conn.request :omie_authentication, app_key: @app_key,
      app_secret: @app_secret
    conn.request :json
    conn.response :json
  end
end

Instance Attribute Details

#app_keyObject (readonly)

Returns the value of attribute app_key.



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

def app_key
  @app_key
end

#app_secretObject (readonly)

Returns the value of attribute app_secret.



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

def app_secret
  @app_secret
end

Instance Method Details

#customerObject



25
26
27
# File 'lib/omie/client.rb', line 25

def customer
  @customer ||= API::Customer.new(conn)
end

#service_invoiceObject



33
34
35
# File 'lib/omie/client.rb', line 33

def service_invoice
  @service_invoice ||= API::ServiceInvoice.new(conn)
end

#service_orderObject



29
30
31
# File 'lib/omie/client.rb', line 29

def service_order
  @service_order ||= API::ServiceOrder.new(conn)
end