Class: Bambora::Builders::Headers
- Inherits:
-
Object
- Object
- Bambora::Builders::Headers
- Defined in:
- lib/bambora/builders/headers.rb
Overview
Builds Headers for HTTP requests.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#sub_merchant_id ⇒ Object
readonly
Returns the value of attribute sub_merchant_id.
Instance Method Summary collapse
-
#build ⇒ Hash
Builds a header object.
-
#initialize(options = {}) ⇒ Headers
constructor
Initialize a new Headers object.
Constructor Details
#initialize(options = {}) ⇒ Headers
Initialize a new Headers object.
17 18 19 20 21 |
# File 'lib/bambora/builders/headers.rb', line 17 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/bambora/builders/headers.rb', line 8 def api_key @api_key end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/bambora/builders/headers.rb', line 8 def content_type @content_type end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
8 9 10 |
# File 'lib/bambora/builders/headers.rb', line 8 def merchant_id @merchant_id end |
#sub_merchant_id ⇒ Object (readonly)
Returns the value of attribute sub_merchant_id.
8 9 10 |
# File 'lib/bambora/builders/headers.rb', line 8 def sub_merchant_id @sub_merchant_id end |
Instance Method Details
#build ⇒ Hash
Builds a header object.
27 28 29 30 31 32 33 34 |
# File 'lib/bambora/builders/headers.rb', line 27 def build headers = { 'Authorization' => "Passcode #{passcode}", } headers['Content-Type'] = content_type if content_type headers['Sub-Merchant-Id'] = sub_merchant_id if sub_merchant_id headers end |