class Freemle::Client

Constants

BASE_URL
VERSION

Attributes

api_key[RW]
app_name[RW]
base_url[RW]

Public Class Methods

new(opts) click to toggle source

Initialize a Freemle client.

@example

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

@params [ Hash ] opts Options for the client,

optionally including base_url.

@return [ Freemle::Client ]

@since 1.0.0

# 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

Public Instance Methods

customers() click to toggle source

Access the customer resource.

@example

client.customers

@return [ Freemle::Client::Resource ] entry to the customer resource.

@since 1.0.0

# File lib/freemle/client.rb, line 38
def customers
  @customers ||= new_resource(self, :customer, :customers)
end
invoices() click to toggle source

Access the invoice resource.

@example

client.invoices

@return [ Freemle::Client::Resource ] entry to the invoice resource.

@since 1.0.0

# File lib/freemle/client.rb, line 50
def invoices
  @invoices ||= new_resource(self, :invoice, :invoices)
end

Private Instance Methods

new_resource(*args) click to toggle source

Creates a freemle client resource based on the passed configuration

@return [ Freemle::Client::Resource ] entry to a resource.

@since 1.0.1

# File lib/freemle/client.rb, line 61
def new_resource(*args)
  Freemle::Client::Resource.new(*args)
end