Class: Booker::CustomerClient
- Includes:
- CustomerREST
- Defined in:
- lib/booker/customer_client.rb
Constant Summary
Constants included from CommonREST
Booker::CommonREST::DEFAULT_PAGINATION_PARAMS
Constants inherited from Client
Instance Attribute Summary
Attributes inherited from Client
#base_url, #client_id, #client_secret, #temp_access_token, #temp_access_token_expires_at, #token_store, #token_store_callback_method
Instance Method Summary collapse
- #get_access_token ⇒ Object
-
#initialize(options = {}) ⇒ CustomerClient
constructor
A new instance of CustomerClient.
Methods included from CustomerREST
#create_appointment, #create_class_appointment, #run_class_availability, #run_multi_spa_multi_sub_category_availability
Methods included from CommonREST
#confirm_appointment, #get_online_booking_settings
Methods inherited from Client
#access_token, #get, #get_booker_resources, #handle_errors!, #log_issue, #paginated_request, #post, #put
Constructor Details
#initialize(options = {}) ⇒ CustomerClient
Returns a new instance of CustomerClient.
5 6 7 8 9 10 |
# File 'lib/booker/customer_client.rb', line 5 def initialize(={}) self.base_url = ENV['BOOKER_CUSTOMER_SERVICE_URL'] || 'https://apicurrent-app.booker.ninja/webservice4/json/CustomerService.svc' self.token_store = GenericTokenStore self.token_store_callback_method = :update_booker_access_token! super end |
Instance Method Details
#get_access_token ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/booker/customer_client.rb', line 12 def get_access_token = { client_id: self.client_id, client_secret: self.client_secret, grant_type: 'client_credentials' } response = get("/access_token", , nil).parsed_response raise Booker::InvalidApiCredentials.new(, response) unless response.present? self.temp_access_token_expires_at = Time.now + response['expires_in'].to_i.seconds self.temp_access_token = response['access_token'] update_token_store self.temp_access_token end |