Class: ShareASale::Request
- Inherits:
-
Struct
- Object
- Struct
- ShareASale::Request
- Defined in:
- lib/share_a_sale.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
-
#date ⇒ Object
Returns the value of attribute date.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
-
#options ⇒ Object
Returns the value of attribute options.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #authentication_hash ⇒ Object
- #custom_headers ⇒ Object
- #date_string ⇒ Object
- #execute! ⇒ Object
- #string_to_hash ⇒ Object
- #url ⇒ Object
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def action @action end |
#api_secret ⇒ Object
Returns the value of attribute api_secret
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def api_secret @api_secret end |
#date ⇒ Object
Returns the value of attribute date
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def date @date end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def merchant_id @merchant_id end |
#options ⇒ Object
Returns the value of attribute options
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def end |
#token ⇒ Object
Returns the value of attribute token
25 26 27 |
# File 'lib/share_a_sale.rb', line 25 def token @token end |
Instance Method Details
#authentication_hash ⇒ Object
34 35 36 |
# File 'lib/share_a_sale.rb', line 34 def authentication_hash Digest::SHA256.hexdigest(string_to_hash).upcase end |
#custom_headers ⇒ Object
43 44 45 46 47 48 |
# File 'lib/share_a_sale.rb', line 43 def custom_headers { "x-ShareASale-Date" => date_string, "x-ShareASale-Authentication" => authentication_hash } end |
#date_string ⇒ Object
26 27 28 |
# File 'lib/share_a_sale.rb', line 26 def date_string date.strftime("%a, %d %b %Y %H:%M:%S GMT") end |
#execute! ⇒ Object
50 51 52 |
# File 'lib/share_a_sale.rb', line 50 def execute! RestClient.get(url, custom_headers) end |
#string_to_hash ⇒ Object
30 31 32 |
# File 'lib/share_a_sale.rb', line 30 def string_to_hash "#{token}:#{date_string}:#{action}:#{api_secret}" end |
#url ⇒ Object
38 39 40 41 |
# File 'lib/share_a_sale.rb', line 38 def url params = [['merchantId', merchant_id], ['token', token], ['version', SHARE_A_SALE_VERSION], ['action', action], ['date', date.strftime("%D")]] + .to_a URI::HTTPS.build(host: SHARE_A_SALE_HOST, path: SHARE_A_SALE_PATH, query: URI.encode_www_form(params)).to_s end |