Class: Freemle::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/freemle/client.rb,
lib/freemle/client/version.rb,
lib/freemle/client/resource.rb

Defined Under Namespace

Classes: Resource

Constant Summary collapse

BASE_URL =
'https://www.freemle.com/api'
VERSION =
'1.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Freemle::Client

Initialize a Freemle client.

Examples:

Freemle::Client.new(
  app_name: <application-name, chosen in freemle.com>
  api_key: <api-key, as provided by freemle.com>
)

Since:

  • 1.0.0



24
25
26
27
28
# File 'lib/freemle/client.rb', line 24

def initialize(opts)
  self.base_url = opts.fetch(:base_url, BASE_URL)
  self.app_name = opts.fetch(:app_name)
  self.api_key = opts.fetch(:api_key)
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



8
9
10
# File 'lib/freemle/client.rb', line 8

def api_key
  @api_key
end

#app_nameObject

Returns the value of attribute app_name.



8
9
10
# File 'lib/freemle/client.rb', line 8

def app_name
  @app_name
end

#base_urlObject

Returns the value of attribute base_url.



8
9
10
# File 'lib/freemle/client.rb', line 8

def base_url
  @base_url
end

Instance Method Details

#customersFreemle::Client::Resource

Access the customer resource.

Examples:

client.customers

Returns:

Since:

  • 1.0.0



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

def customers
  @customers ||= new_resource(self, :customer, :customers)
end

#invoicesFreemle::Client::Resource

Access the invoice resource.

Examples:

client.invoices

Returns:

Since:

  • 1.0.0



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

def invoices
  @invoices ||= new_resource(self, :invoice, :invoices)
end