mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
added directo handler for interaction with billing system
This commit is contained in:
parent
d9696014ff
commit
0259dd7fec
8 changed files with 286 additions and 1 deletions
30
app/services/eis_billing/send_data_to_directo.rb
Normal file
30
app/services/eis_billing/send_data_to_directo.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module EisBilling
|
||||
class SendDataToDirecto < EisBilling::Base
|
||||
def self.send_request(object_data:, monthly:, dry:)
|
||||
base_request(object_data: object_data, monthly: monthly, dry: dry)
|
||||
end
|
||||
|
||||
def self.base_request(object_data:, monthly:, dry:)
|
||||
prepared_data = {
|
||||
invoice_data: object_data,
|
||||
monthly: monthly,
|
||||
dry: dry,
|
||||
initiator: 'registry'
|
||||
}
|
||||
|
||||
uri = URI(invoice_generator_url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
headers = {
|
||||
'Authorization' => 'Bearer foobar',
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => TOKEN
|
||||
}
|
||||
|
||||
http.post(invoice_generator_url, prepared_data.to_json, headers)
|
||||
end
|
||||
|
||||
def self.invoice_generator_url
|
||||
"#{BASE_URL}/api/v1/directo/directo"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue