class MyData::Client
Constants
- BASE_URL
Public Class Methods
new(user_id:, subscription_key:, environment:)
click to toggle source
# File lib/my_data/client.rb, line 10 def initialize(user_id:, subscription_key:, environment:) @user_id = user_id @subscription_key = subscription_key @environment = environment end
Public Instance Methods
cancel_invoice(mark:)
click to toggle source
# File lib/my_data/client.rb, line 44 def cancel_invoice(mark:) response = connection.post("CancelInvoice") do |req| req.params["mark"] = mark end parse_response( response, resource: MyData::Resources::Response, root: "response_doc" ) end
request_docs(mark:, next_partition_key: nil, next_row_key: nil)
click to toggle source
# File lib/my_data/client.rb, line 26 def request_docs(mark:, next_partition_key: nil, next_row_key: nil) base_request_docs( endpoint: "RequestDocs", mark: mark, next_partition_key: next_partition_key, next_row_key: next_row_key ) end
request_transmitted_docs(mark:, next_partition_key: nil, next_row_key: nil)
click to toggle source
# File lib/my_data/client.rb, line 35 def request_transmitted_docs(mark:, next_partition_key: nil, next_row_key: nil) base_request_docs( endpoint: "RequestTransmittedDocs", mark: mark, next_partition_key: next_partition_key, next_row_key: next_row_key ) end
send_invoices(doc:)
click to toggle source
# File lib/my_data/client.rb, line 16 def send_invoices(doc:) response = connection.post("SendInvoices", doc) parse_response( response, resource: MyData::Resources::Response, root: "response_doc" ) end
Private Instance Methods
base_request_docs(endpoint:, mark:, next_partition_key:, next_row_key:)
click to toggle source
# File lib/my_data/client.rb, line 58 def base_request_docs(endpoint:, mark:, next_partition_key:, next_row_key:) params = { mark: mark } if next_partition_key && next_row_key params.merge!(nextPartitionKey: next_partition_key, nextRowKey: next_row_key) end response = connection.get(endpoint, params) parse_response( response, resource: MyData::Resources::Inv::RequestDoc, root: "requested_doc" ) end
connection()
click to toggle source
# File lib/my_data/client.rb, line 74 def connection @connection ||= Faraday.new(BASE_URL[@environment]) do |conn| conn.headers = headers end end
headers()
click to toggle source
# File lib/my_data/client.rb, line 84 def headers @headers ||= { "Content-Type" => "application/xml", "Accept" => "application/xml", "aade-user-id" => @user_id, "Ocp-Apim-Subscription-Key" => @subscription_key } end
parse_response(response, resource:, root:)
click to toggle source
# File lib/my_data/client.rb, line 80 def parse_response(response, resource:, root:) MyData::ResponseParser.new(response, resource: resource, root: root) end