Module: Fullscriptapi

Extended by:
AuthenticationEndpoints, Servers
Defined in:
lib/fullscriptapi.rb,
lib/fullscriptapi/servers.rb,
lib/fullscriptapi/version.rb,
lib/fullscriptapi/access_token.rb,
lib/fullscriptapi/authentication_endpoints.rb,
lib/fullscriptapi/authentication_endpoints/refresh_token.rb,
lib/fullscriptapi/authentication_endpoints/create_an_oauth_token.rb

Defined Under Namespace

Modules: AuthenticationEndpoints, Servers Classes: AccessToken

Constant Summary collapse

VERSION =
"0.3.5"

Constants included from Servers

Servers::SERVERS

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Servers

get_server

Methods included from AuthenticationEndpoints::RefreshToken

#refresh_token

Methods included from AuthenticationEndpoints::CreateAnOauthToken

create_an_oauth_token

Class Attribute Details

.client_idObject

Returns the value of attribute client_id.



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

def client_id
  @client_id
end

.redirect_uriObject

Returns the value of attribute redirect_uri.



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

def redirect_uri
  @redirect_uri
end

.secretObject

Returns the value of attribute secret.



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

def secret
  @secret
end

.serverObject

Returns the value of attribute server.



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

def server
  @server
end

.tokenObject

Returns the value of attribute token.



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

def token
  @token
end

Class Method Details

.config {|_self| ... } ⇒ Object Also known as: new

Yields:

  • (_self)

Yield Parameters:

  • _self (Fullscriptapi)

    the object that the method was called on



15
16
17
18
19
# File 'lib/fullscriptapi.rb', line 15

def config
  yield self if block_given?

  self
end

.method_missing(name, *args, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fullscriptapi.rb', line 27

def method_missing(name, *args, &block)
  @requested_method_hash = api_json_meta.detect { |v| v[:api_method] == name.to_s }
  
  super unless requested_method_hash

  refresh_token if stale_token? # TO-DO: write logic to improve token refresh

  params = excon_params(*args)
  
  Excon.send(*params)
end

.use_token(opts = {}) ⇒ Object



22
23
24
25
# File 'lib/fullscriptapi.rb', line 22

def use_token(opts = {})
  # pass in a hash containing token attributes e.g. access_token, refresh_token, expires_*
  @token = Fullscriptapi::AccessToken.new(opts)
end