class Namely::Connection
Attributes
access_token[R]
subdomain[R]
Public Class Methods
new(options)
click to toggle source
Instantiate a new connection to the server.
@param [Hash] options @option options [String] access_token
(required) @option options [String] subdomain (required)
@example
Namely.configure do |config| config.access_token = "your_access_token" config.subdomain = "your-organization" end
@raise [KeyError] if access_token
and subdomain aren't provided.
@return [Connection]
# File lib/namely/connection.rb, line 18 def initialize(options) @access_token = options.fetch(:access_token) @subdomain = options.fetch(:subdomain) rescue KeyError raise ArgumentError, "Please supply an access_token and subdomain." end
Public Instance Methods
countries()
click to toggle source
Return a Collection
of countries.
@return [Collection]
# File lib/namely/connection.rb, line 28 def countries collection("countries") end
currency_types()
click to toggle source
Return a Collection
of currency types.
@return [Collection]
# File lib/namely/connection.rb, line 35 def currency_types collection("currency_types") end
events()
click to toggle source
Return a Collection
of countries.
@return [Collection]
# File lib/namely/connection.rb, line 42 def events collection("events") end
fields()
click to toggle source
Return a Collection
of profile fields.
@return [Collection]
# File lib/namely/connection.rb, line 49 def fields collection("profiles/fields") end
job_tiers()
click to toggle source
Return a Collection
of job tiers.
@return [Collection]
# File lib/namely/connection.rb, line 56 def job_tiers collection("job_tiers") end
job_titles()
click to toggle source
Return a Collection
of job titles.
@return [Collection]
# File lib/namely/connection.rb, line 63 def job_titles collection("job_titles") end
profiles()
click to toggle source
Return a Collection
of profiles.
@return [Collection]
# File lib/namely/connection.rb, line 70 def profiles collection("profiles", paged: true) end
reports()
click to toggle source
Return a Collection
of reports.
@return [Collection]
# File lib/namely/connection.rb, line 77 def reports collection("reports") end
Private Instance Methods
collection(endpoint, options = {})
click to toggle source
# File lib/namely/connection.rb, line 85 def collection(endpoint, options = {}) Namely::Collection.new(gateway(endpoint, options)) end
gateway(endpoint, options = {})
click to toggle source
# File lib/namely/connection.rb, line 89 def gateway(endpoint, options = {}) ResourceGateway.new(options.merge( access_token: access_token, endpoint: endpoint, subdomain: subdomain, )) end