class SpreedlyCore::Gateway

Attributes

auth_modes[R]
gateway_type[R]
name[R]
redacted[R]
supports_authorize[R]
supports_capture[R]
supports_credit[R]
supports_purchase[R]
supports_void[R]
token[R]

Public Class Methods

all() click to toggle source

returns an array of all the Gateways owned by the account

# 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) click to toggle source
# File lib/spreedly-core-ruby/gateway.rb, line 33
def self.create(gateway_options)
  raise ArgumentError.new("gateway_options must be a hash") unless gateway_options.is_a?(Hash)
  
  opts = {
    :headers => {"Content-Type" => "application/xml"},
    :body => gateway_options.to_xml(:root => :gateway, :dasherize => false),
  }

  verify_post("/gateways.xml", opts) do |response|
    return new response.parsed_response["gateway"]
  end
end
new(attrs={}) click to toggle source
Calls superclass method SpreedlyCore::Base::new
# File lib/spreedly-core-ruby/gateway.rb, line 46
def initialize(attrs={})
  attrs.merge!(attrs.delete("characteristics") || {})
  super(attrs)
end
supported_gateways() click to toggle source

returns an array of Gateway which are supported

# File lib/spreedly-core-ruby/gateway.rb, line 8
def self.supported_gateways
  verify_options("/gateways.xml") do |response|
    response.parsed_response["gateways"]["gateway"].map{|h| new(h) }
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/spreedly-core-ruby/gateway.rb, line 55
def ==(other)
  self.token == other.token
end
use!() click to toggle source
# File lib/spreedly-core-ruby/gateway.rb, line 51
def use!
  self.class.gateway_token = self.token
end