Class: Swisspost::BaseService

Inherits:
Object
  • Object
show all
Defined in:
lib/swisspost/base_service.rb

Direct Known Subclasses

AddressService, BarcodeService, PriceService

Instance Method Summary collapse

Instance Method Details

#access_token(scope) ⇒ Object



20
21
22
# File 'lib/swisspost/base_service.rb', line 20

def access_token(scope)
  @access_token ||= Auth.new.get_access_token(scope)
end

#httpx_apikeyObject



13
14
15
16
17
18
# File 'lib/swisspost/base_service.rb', line 13

def httpx_apikey
  @httpx_apikey ||= HTTPX.with(headers: {
    "X-Apim-Api-Key" => "77b97c82-5324-4964-b97c-825324f964cb",
    "Content-Type" => "application/json"
  })
end

#httpx_oauth(scope) ⇒ Object



6
7
8
9
10
11
# File 'lib/swisspost/base_service.rb', line 6

def httpx_oauth(scope)
  @httpx_oauth ||= HTTPX.with(headers: {
    "Authorization" => "Bearer #{access_token(scope)}",
    "Content-Type" => "application/json"
  })
end