Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aces encoding #21

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/operations/aces/encode_account_transfer_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class EncodeAccountTransferRequest
# @param [Aces::AccountTransferRequest] request
# @return [Dry::Result<String>]
def call(request)
encode_soap_envelope(request)
envelope = encode_soap_envelope(request)
encode_soap_body(envelope, request)
end

protected
Expand Down Expand Up @@ -42,17 +43,16 @@ def encode_soap_header(xml, request)
end
end

def encode_soap_body(xml, request)
xml[:soap].Body do |header|
header << request.raw_body
end
def encode_soap_body(built, request)
str = "<\/soap:Header>"
pos = built.value!.index(str)
Success(built.value!.insert(pos + str.size, "<soap:Body>#{request.raw_body}<\/soap:Body>"))
end

def encode_soap_envelope(request)
builder = Nokogiri::XML::Builder.new do |xml|
xml[:soap].Envelope({ "xmlns:soap" => "http://www.w3.org/2003/05/soap-envelope" }) do |envelope|
encode_soap_header(envelope, request)
encode_soap_body(envelope, request)
end
end
Success(builder.to_xml)
Expand Down
3 changes: 2 additions & 1 deletion app/operations/aces/submit_account_transfer_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def read_endpoint_setting
end

def submit_request(service_uri, payload)
clean_payload = payload.to_s.gsub("<?xml version=\"1.0\"?>", "").gsub("<?xml version=\"1.0\"??>", "")
result = Try do
Faraday.post(
service_uri,
payload,
clean_payload,
"Content-Type" => "application/soap+xml"
)
end
Expand Down
1 change: 0 additions & 1 deletion app/operations/transfers/to_aces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def initiate_transfer(payload, service, params)

def record_transfer(service, params, response)
payload = JSON.parse(params)
puts payload
Transfers::Create.new.call({ service: service,
application_identifier: payload["family"]["magi_medicaid_applications"][0]["hbx_id"],
family_identifier: payload["family"]["hbx_id"],
Expand Down