Class: MyData::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/my_data/client.rb

Constant Summary collapse

BASE_URL =
{
  sandbox: "https://mydataapidev.aade.gr",
  production: "https://mydatapi.aade.gr/myDATA/"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, subscription_key:, environment:) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
# 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.to_sym
end

Instance Method Details

#cancel_invoice(mark:) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# 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) ⇒ Object



26
27
28
29
30
31
32
33
# 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) ⇒ Object



35
36
37
38
39
40
41
42
# 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:) ⇒ Object



16
17
18
19
20
21
22
23
24
# 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