Class: Sendcloud::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sendcloud/base.rb

Direct Known Subclasses

ParcelResource, ShippingMethod

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret) ⇒ Base

Returns a new instance of Base.

Parameters:

  • api_key (String)

    the ‘apikey` from your account settings

  • api_secret (String)

    the ‘apisecret` from your account settings



14
15
16
17
# File 'lib/sendcloud/base.rb', line 14

def initialize(api_key, api_secret)
  self.api_key = api_key
  self.api_secret = api_secret
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/sendcloud/base.rb', line 9

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



9
10
11
# File 'lib/sendcloud/base.rb', line 9

def api_secret
  @api_secret
end

Instance Method Details

#authHash

get the auth hash to use for all the requests since the sendcloud api uses basic authentication it will be used in the subclasses like this: ‘HTTParty.get(“twitter.com/statuses/public_timeline.json”, :basic_auth => auth)`

Returns:

  • (Hash)

    the basic auth hash based on the api_key and api_secret



25
26
27
# File 'lib/sendcloud/base.rb', line 25

def auth
  { username: api_key, password: api_secret}
end