Class: Namely::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/namely/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Connection

Instantiate a new connection to the server.

Examples:

Namely.configure do |config|
  config.access_token = "your_access_token"
  config.subdomain = "your-organization"
end

Parameters:

  • options (Hash)

Options Hash (options):

  • access_token (String) — default: required
  • subdomain (String) — default: required

Raises:

  • (KeyError)

    if access_token and subdomain aren’t provided.



18
19
20
21
22
23
# 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

Instance Method Details

#countriesCollection

Return a Collection of countries.

Returns:



28
29
30
# File 'lib/namely/connection.rb', line 28

def countries
  collection("countries")
end

#currency_typesCollection

Return a Collection of currency types.

Returns:



35
36
37
# File 'lib/namely/connection.rb', line 35

def currency_types
  collection("currency_types")
end

#eventsCollection

Return a Collection of countries.

Returns:



42
43
44
# File 'lib/namely/connection.rb', line 42

def events
  collection("events")
end

#fieldsCollection

Return a Collection of profile fields.

Returns:



49
50
51
# File 'lib/namely/connection.rb', line 49

def fields
  collection("profiles/fields")
end

#job_tiersCollection

Return a Collection of job tiers.

Returns:



56
57
58
# File 'lib/namely/connection.rb', line 56

def job_tiers
  collection("job_tiers")
end

#job_titlesCollection

Return a Collection of job titles.

Returns:



63
64
65
# File 'lib/namely/connection.rb', line 63

def job_titles
  collection("job_titles")
end

#profilesCollection

Return a Collection of profiles.

Returns:



70
71
72
# File 'lib/namely/connection.rb', line 70

def profiles
  collection("profiles", paged: true)
end

#reportsCollection

Return a Collection of reports.

Returns:



77
78
79
# File 'lib/namely/connection.rb', line 77

def reports
  collection("reports")
end