Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Update gateway end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
vpuzzella committed May 9, 2024
1 parent 7898d6c commit 108b7b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/spreedly/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/spreedly/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/spreedly/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 108b7b6

Please sign in to comment.