Class: SpreedlyCore::Gateway
- Defined in:
- lib/spreedly-core-ruby/gateway.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auth_modes ⇒ Object
readonly
Returns the value of attribute auth_modes.
-
#gateway_type ⇒ Object
readonly
Returns the value of attribute gateway_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#redacted ⇒ Object
readonly
Returns the value of attribute redacted.
-
#supports_authorize ⇒ Object
readonly
Returns the value of attribute supports_authorize.
-
#supports_capture ⇒ Object
readonly
Returns the value of attribute supports_capture.
-
#supports_credit ⇒ Object
readonly
Returns the value of attribute supports_credit.
-
#supports_purchase ⇒ Object
readonly
Returns the value of attribute supports_purchase.
-
#supports_void ⇒ Object
readonly
Returns the value of attribute supports_void.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.all ⇒ Object
returns an array of all the Gateways owned by the account.
- .create(gateway_options) ⇒ Object
-
.supported_gateways ⇒ Object
returns an array of Gateway which are supported.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(attrs = {}) ⇒ Gateway
constructor
A new instance of Gateway.
- #use! ⇒ Object
Methods inherited from Base
configure, environment_key, gateway_token, gateway_token=, verify_get, verify_options, verify_post, verify_put, verify_request
Constructor Details
#initialize(attrs = {}) ⇒ Gateway
Returns a new instance of Gateway.
46 47 48 49 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 46 def initialize(attrs={}) attrs.merge!(attrs.delete("characteristics") || {}) super(attrs) end |
Instance Attribute Details
#auth_modes ⇒ Object (readonly)
Returns the value of attribute auth_modes.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def auth_modes @auth_modes end |
#gateway_type ⇒ Object (readonly)
Returns the value of attribute gateway_type.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def gateway_type @gateway_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def name @name end |
#redacted ⇒ Object (readonly)
Returns the value of attribute redacted.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def redacted @redacted end |
#supports_authorize ⇒ Object (readonly)
Returns the value of attribute supports_authorize.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def @supports_authorize end |
#supports_capture ⇒ Object (readonly)
Returns the value of attribute supports_capture.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def supports_capture @supports_capture end |
#supports_credit ⇒ Object (readonly)
Returns the value of attribute supports_credit.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def supports_credit @supports_credit end |
#supports_purchase ⇒ Object (readonly)
Returns the value of attribute supports_purchase.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def supports_purchase @supports_purchase end |
#supports_void ⇒ Object (readonly)
Returns the value of attribute supports_void.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def supports_void @supports_void end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 3 def token @token end |
Class Method Details
.all ⇒ Object
returns an array of all the Gateways owned by the account
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 15 def self.all verify_get("/gateways.xml") do |response| # will return Hash if only 1 gateways->gateway, Array otherwise gateways = begin response.parsed_response["gateways"]["gateway"] rescue nil end if gateways gateways = [gateways] unless gateways.is_a?(Array) return gateways.collect{|gateway_hash| new gateway_hash} end end return [] end |
.create(gateway_options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 33 def self.create() raise ArgumentError.new("gateway_options must be a hash") unless .is_a?(Hash) opts = { :headers => {"Content-Type" => "application/xml"}, :body => .to_xml(:root => :gateway, :dasherize => false), } verify_post("/gateways.xml", opts) do |response| return new response.parsed_response["gateway"] end end |
.supported_gateways ⇒ Object
returns an array of Gateway which are supported
8 9 10 11 12 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 8 def self.supported_gateways ("/gateways.xml") do |response| response.parsed_response["gateways"]["gateway"].map{|h| new(h) } end end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 55 def ==(other) self.token == other.token end |
#use! ⇒ Object
51 52 53 |
# File 'lib/spreedly-core-ruby/gateway.rb', line 51 def use! self.class.gateway_token = self.token end |