Skip to content

Instantly share code, notes, and snippets.

@makaroni4
Created August 10, 2014 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makaroni4/70c6ba61043ae48f6140 to your computer and use it in GitHub Desktop.
Save makaroni4/70c6ba61043ae48f6140 to your computer and use it in GitHub Desktop.
Реализация отправки Operation данных в Mimimetrics API на Ruby
require 'net/http'
require 'uri'
require 'json'
def send_operation()
data = {
operation: {
operation_id: "24215140440800001402186",
amount: 571.13,
direction: "in",
datetime: "2007-09-01T21:30:04.000+04:00",
status: "success",
sender: "9d6764e0514f6b58",
recipient: "7bc1ea00fd60d100"
}
}
headers = {
"Authorization" => "Token token=4b3e4a2cd7ee1d5078598cac2d5799ab",
"Content-Type" => "application/json",
"Accept" => "application/json"
}
uri = URI('http://mimimetrics.dev/api/v1/operations.json')
req = Net::HTTP::Post.new(uri, headers)
req.body = data.to_json
Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
end
send_operation()
# #<Net::HTTPOK 200 OK readbody=true>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment