Class: Alexa::SMAPI::Client
- Inherits:
-
OAuth2::AccessToken
- Object
- OAuth2::AccessToken
- Alexa::SMAPI::Client
- Includes:
- Endpoints::AccountLinkingManagement, Endpoints::BetaTestManagement, Endpoints::InteractionModelManagement, Endpoints::SkillManagement, Endpoints::SkillValidation, Endpoints::VendorManagement
- Defined in:
- lib/alexa/smapi/client.rb
Instance Method Summary collapse
-
#initialize(client_id, client_secret, refresh_token) ⇒ Client
constructor
A new instance of Client.
- #refresh_token! ⇒ Object
Methods included from Endpoints::VendorManagement
Methods included from Endpoints::SkillValidation
#get_skill_validation, #validate_skill
Methods included from Endpoints::BetaTestManagement
#add_beta_tester, #add_beta_testers, #create_beta_test, #end_beta_test, #get_beta_test, #get_beta_testers, #remove_beta_tester, #remove_beta_testers, #request_feedback_from_tester, #request_feedback_from_testers, #send_reminder_to_tester, #send_reminder_to_testers, #start_beta_test, #update_beta_test
Methods included from Endpoints::AccountLinkingManagement
#delete_account_linking_partner, #get_account_linking_information, #update_account_linking
Methods included from Endpoints::InteractionModelManagement
#get_interaction_model, #update_interaction_model
Methods included from Endpoints::SkillManagement
#create_skill, #delete_skill, #get_skill, #get_skill_resource_status, #get_skills, #update_skill
Constructor Details
#initialize(client_id, client_secret, refresh_token) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/alexa/smapi/client.rb', line 21 def initialize client_id, client_secret, refresh_token Faraday::Utils.default_params_encoder = Faraday::FlatParamsEncoder oauth2 = OAuth2::Client.new client_id, client_secret, :site => "https://api.amazonalexa.com/", :authorize_url => "https://www.amazon.com/ap/oa", :token_url => "https://api.amazon.com/auth/o2/token", :header_format => "%s" params = { refresh_token: refresh_token, header_format: "%s" } super(oauth2, '', params) new_token = self.refresh! @token = new_token.token @expires_in = new_token.expires_in.to_i @expires_at = new_token.expires_at.to_i end |
Instance Method Details
#refresh_token! ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/alexa/smapi/client.rb', line 47 def refresh_token! new_token = self.refresh! @token = new_token.token @expires_in = new_token.expires_in.to_i @expires_at = new_token.expires_at.to_i @token end |