Class: ShareASale::Request
- Inherits:
-
Struct
- Object
- Struct
- ShareASale::Request
- Defined in:
- lib/share_a_sale/request.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
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def action @action end |
#api_secret ⇒ Object
Returns the value of attribute api_secret
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def api_secret @api_secret end |
#date ⇒ Object
Returns the value of attribute date
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def date @date end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def merchant_id @merchant_id end |
#options ⇒ Object
Returns the value of attribute options
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def @options end |
#token ⇒ Object
Returns the value of attribute token
2 3 4 |
# File 'lib/share_a_sale/request.rb', line 2 def token @token end |
Instance Method Details
#authentication_hash ⇒ Object
12 13 14 |
# File 'lib/share_a_sale/request.rb', line 12 def authentication_hash Digest::SHA256.hexdigest(string_to_hash).upcase end |
#custom_headers ⇒ Object
32 33 34 35 36 37 |
# File 'lib/share_a_sale/request.rb', line 32 def custom_headers { "x-ShareASale-Date" => date_string, "x-ShareASale-Authentication" => authentication_hash } end |
#date_string ⇒ Object
4 5 6 |
# File 'lib/share_a_sale/request.rb', line 4 def date_string date.strftime("%a, %d %b %Y %H:%M:%S GMT") end |
#execute! ⇒ Object
39 40 41 |
# File 'lib/share_a_sale/request.rb', line 39 def execute! RestClient.get(url, custom_headers) end |
#string_to_hash ⇒ Object
8 9 10 |
# File 'lib/share_a_sale/request.rb', line 8 def string_to_hash "#{token}:#{date_string}:#{action}:#{api_secret}" end |
#url ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/share_a_sale/request.rb', line 16 def url params = [ ['merchantId', merchant_id], ['token', token], ['version', version], ['action', action], ['date', date.strftime("%D")] ] + .to_a URI::HTTPS.build( host: host, path: path, query: params.map{|p| p.join('=') }.join('&') ).to_s end |