Skip to content

Commit

Permalink
adds report endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
safeforge committed Oct 15, 2024
1 parent ddad9cc commit bd29de7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cardknox/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def post(path, body = {})

def parse(response)
JSON.parse(response.body, symbolize_names: true).tap do |payload|
if payload[:xStatus] != "Approved"
puts payload.inspect

unless ["Approved", "Success"].include?(payload[:xStatus])
raise Error::TransactionFailure.new(payload[:xError], response)
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/cardknox/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ def transaction(command, params = {})
}))
end

def report(command, params = {})
@agent.post("/reportjson", params.merge({
xKey: config.api_key,
xVersion: config.gateway_version,
xSoftwareName: config.software_name,
xSoftwareVersion: config.software_version,
xCommand: command,
}))
end

def status
@agent.get("/status")
end
Expand Down
1 change: 1 addition & 0 deletions spec/lib/cardknox/api/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
describe "Respond to" do
it { is_expected.to(respond_to(:status)) }
it { is_expected.to(respond_to(:transaction)) }
it { is_expected.to(respond_to(:report)) }
end
end

0 comments on commit bd29de7

Please sign in to comment.