Module: RSperantito

Defined in:
lib/rsperantito.rb,
lib/rsperantito/auth.rb,
lib/rsperantito/base.rb,
lib/rsperantito/client.rb,
lib/rsperantito/project.rb,
lib/rsperantito/version.rb,
lib/rsperantito/captation_way.rb

Defined Under Namespace

Classes: Base, CaptationWay, Client, ExceptionAuthenticate, Project

Constant Summary collapse

API_URI =
'https://api.sperant.com/v2/'.freeze
TOKEN_URI =
'https://api.sperant.com/oauth/token'.freeze
VERBS =
%w[get post put delete].freeze
VERSION =
'0.0.1'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_tokenObject (readonly)

Returns the value of attribute client_token.



13
14
15
# File 'lib/rsperantito/auth.rb', line 13

def client_token
  @client_token
end

Class Method Details

.authenticate(client_id, client_secret) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rsperantito/auth.rb', line 15

def authenticate(client_id, client_secret)
  @client_id, @client_secret = client_id, client_secret
  params =
    {grant_type: 'client_credentials',
      client_id: @client_id,
      client_secret: @client_secret}

  response = RestClient::Resource.new(
    TOKEN_URI,
    verify_ssl: false).post(params)
  @client_token = JSON.parse(response)['access_token']
  true
end