diff --git a/lib/spreedly/environment.rb b/lib/spreedly/environment.rb index 5021b58..2b78b9f 100644 --- a/lib/spreedly/environment.rb +++ b/lib/spreedly/environment.rb @@ -142,6 +142,13 @@ def add_gateway(gateway_type, credentials = {}) Gateway.new(xml_doc) end + def update_gateway(gateway_token, credentials: {}, options: {}) + body = update_gateway_body(credentials: credentials, options: options) + puts body + xml_doc = ssl_put(update_gateway_url(gateway_token), body, headers) + Gateway.new(xml_doc) + end + def add_receiver(receiver_type, host_names = nil, credentials = []) body = add_receiver_body(receiver_type, host_names, credentials) xml_doc = ssl_post(add_receiver_url, body, headers) @@ -252,6 +259,13 @@ def add_gateway_body(gateway_type, credentials) end end + def update_gateway_body(credentials: {}, options: {}) + build_xml_request('gateway') do |doc| + add_to_doc(doc, credentials, *credentials.keys) + add_to_doc(doc, options, :description, :merchant_profile_key, :sub_merchant_key) + end + end + def add_receiver_body(receiver_type, host_names, credentials) build_xml_request('receiver') do |doc| doc.receiver_type receiver_type diff --git a/lib/spreedly/gateway.rb b/lib/spreedly/gateway.rb index b8d2238..99047fb 100644 --- a/lib/spreedly/gateway.rb +++ b/lib/spreedly/gateway.rb @@ -3,7 +3,7 @@ module Spreedly class Gateway < Model - field :gateway_type, :state, :name + field :gateway_type, :state, :name, :description attr_reader :credentials def initialize(xml_doc) diff --git a/lib/spreedly/urls.rb b/lib/spreedly/urls.rb index 746396d..6568585 100644 --- a/lib/spreedly/urls.rb +++ b/lib/spreedly/urls.rb @@ -98,6 +98,10 @@ def add_gateway_url "#{base_url}/v1/gateways.xml" end + def update_gateway_url(gateway_token) + "#{base_url}/v1/gateways/#{gateway_token}.xml" + end + def receiver_options_url "#{base_url}/v1/receivers_options.xml" end