Class: Billimatic::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/billimatic/client.rb', line 5

def initialize(token)
  @http = Http.new(token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



3
4
5
# File 'lib/billimatic/client.rb', line 3

def http
  @http
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/billimatic/client.rb', line 9

def authenticated?
  http.get("/companies/search?cnpj=auth_test") do |response|
    response.code == 200
  end
rescue RequestError => e
  raise e unless e.code == 401
  false
end

#companiesObject



46
47
48
# File 'lib/billimatic/client.rb', line 46

def companies
  Resources::Company.new(http)
end

#contractsObject



30
31
32
# File 'lib/billimatic/client.rb', line 30

def contracts
  Resources::Contract.new(http)
end

#email_templatesObject



62
63
64
# File 'lib/billimatic/client.rb', line 62

def email_templates
  Resources::EmailTemplate.new(http)
end

#invoice_rulesObject



42
43
44
# File 'lib/billimatic/client.rb', line 42

def invoice_rules
  Resources::InvoiceRule.new(http)
end

#invoice_templatesObject



38
39
40
# File 'lib/billimatic/client.rb', line 38

def invoice_templates
  Resources::InvoiceTemplate.new(http)
end

#invoicesObject



34
35
36
# File 'lib/billimatic/client.rb', line 34

def invoices
  Resources::Invoice.new(http)
end

#organizationsObject



18
19
20
# File 'lib/billimatic/client.rb', line 18

def organizations
  Resources::Organization.new(http)
end

#peopleObject



50
51
52
# File 'lib/billimatic/client.rb', line 50

def people
  Resources::Person.new(http)
end

#plansObject



22
23
24
# File 'lib/billimatic/client.rb', line 22

def plans
  Resources::Plan.new(http)
end

#service_itemsObject



54
55
56
# File 'lib/billimatic/client.rb', line 54

def service_items
  Resources::ServiceItem.new(http)
end

#subscriptionsObject



26
27
28
# File 'lib/billimatic/client.rb', line 26

def subscriptions
  Resources::Subscription.new(http)
end

#webhooksObject



58
59
60
# File 'lib/billimatic/client.rb', line 58

def webhooks
  Resources::Webhook.new(http)
end