Class: Credly::Client

Inherits:
Object
  • Object
show all
Includes:
Actions::BadgeTemplates, Actions::Badges, Actions::IssuerAuthorizations, Actions::OBI, Actions::Organizations, Actions::Workforce
Defined in:
lib/credly-ruby/client.rb

Constant Summary collapse

BASE_URL_P =
'https://api.credly.com'
BASE_URL_S =
'https://sandbox-api.credly.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Actions::Workforce

#employee_create, #employee_data_api_get, #employee_delete, #employee_get, #employee_invite, #employee_list, #employee_update

Methods included from Actions::IssuerAuthorizations

#grantor_list, #issuer_deauthorize, #issuer_list

Methods included from Actions::OBI

#obi_badge_assertion_get, #obi_badge_class_get, #obi_issuer_get

Methods included from Actions::Organizations

#organization_event_get, #organization_event_list, #organization_get, #organization_tokens_list, #organization_update, #organizations_list

Methods included from Actions::BadgeTemplates

#badge_template_get, #badge_templates_list

Methods included from Actions::Badges

#badge_delete, #badge_issue, #badge_list, #badge_list_bulk, #badge_replace, #badge_revoke

Constructor Details

#initialize(auth_token:, version: 'v1', sandbox: false) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
# File 'lib/credly-ruby/client.rb', line 17

def initialize(auth_token:, version: 'v1', sandbox: false)
  @base_url     = sandbox ? BASE_URL_S : BASE_URL_P
  @url          = [@base_url, version].join('/')
  @version      = version
  @auth_token   = auth_token
  @sandbox      = sandbox
  @connection   = Connection.new(@url, @auth_token)
end

Instance Attribute Details

#auth_tokenObject

Returns the value of attribute auth_token.



11
12
13
# File 'lib/credly-ruby/client.rb', line 11

def auth_token
  @auth_token
end

#sandboxObject

Returns the value of attribute sandbox.



12
13
14
# File 'lib/credly-ruby/client.rb', line 12

def sandbox
  @sandbox
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/credly-ruby/client.rb', line 11

def url
  @url
end

Instance Method Details

#base_urlObject



35
36
37
# File 'lib/credly-ruby/client.rb', line 35

def base_url
  @sandbox ? BASE_URL_S : BASE_URL_P
end

#connectionObject



26
27
28
# File 'lib/credly-ruby/client.rb', line 26

def connection
  @connection ||= Connection.new(@url, @auth_token)
end