my_data 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21734192525f3cdc66a24be64cfc3f147647f8decb6f71a6cd17094f5fc79bcb
4
- data.tar.gz: ce56b3d0ec170898a593cbfab881e843c1a89a3e3de6a055dce39f0d302f6a67
3
+ metadata.gz: 3273ccb4d8c804998eb68ca24672853ac653d978c345aa48defa92630f9e38ef
4
+ data.tar.gz: 2405e53492df2ed8a5b6a7767a047970ba5ff023ebe96579c2fe7dd1e9ba8729
5
5
  SHA512:
6
- metadata.gz: e18093c80a0108ee8fe815ab50ca359cc019e2346a297b62e45d7c27f83652cab79461c5549bf6e69cad6752a546ae536bf84a10ecf23e320b2bdbb426cb932b
7
- data.tar.gz: 9d64a6162fbb18bb511159e8c43d2117c795e91e222ce7e5ca10523b6cc7aea72b6bf9412245185537dadd7a512ade270f46672278b982f8377e86a68d5e3ca1
6
+ metadata.gz: 7b06573c6884bf67928aee498df4dad7e27150c64343a7fbf55df81cba1101aee4582b414e4c5b043eef9ec59b231d1eb0d8a7fd7f52d88e6ef55283554f0dfa
7
+ data.tar.gz: 0023b41d611bfb42026195a57d9a387e551f2025ba6057a59e46a843a78504a6a06bbaa47a0142591d9d867f636ee1fd3dd8dfe7ca85445a2ca1d3c2c59e9aed
data/README.md CHANGED
@@ -23,7 +23,7 @@ There are all the [resources](https://github.com/mikezaby/my_data/tree/master/li
23
23
  that are specified by the given
24
24
  [xsd files](https://www.aade.gr/sites/default/files/2020-11/version%20v1.0.2%20XSDs.zip) from AADE.
25
25
 
26
- e.x.
26
+ e.g.
27
27
  ```irb
28
28
  irb> MyData::Resources::Inv::PartyType
29
29
  => MyData::Resources::Inv::PartyType vat_number: string, country: string, branch: integer, name: string, address: MyData::Resources::Inv::AddressType
@@ -31,14 +31,18 @@ irb> MyData::Resources::Inv::PartyType
31
31
 
32
32
  ## Usage
33
33
 
34
- ##### Initialize client
34
+ #### Initialize client
35
35
  ```ruby
36
- client = MyData::Client.new(user_id: "johndoe", subscription_key: "c9b79ff1841fb5cfecc66e1ea5a29b4d")
36
+ # You could set environment to :sandbox or :production
37
+ client = MyData::Client.new(
38
+ user_id: "johndoe",
39
+ subscription_key: "c9b79ff1841fb5cfecc66e1ea5a29b4d",
40
+ environment: :sandbox
41
+ )
37
42
  ```
38
43
 
39
- ##### Send invoices
44
+ #### Send invoices
40
45
  ```ruby
41
- # send invoices
42
46
  invoice_data = {
43
47
  issuer: { vat_number: "111111111", country: "GR", branch: 0 },
44
48
  invoice_header: { series: "A", aa: "1", issue_date: "2021-02-21", invoice_type: "11.2", currency: "EUR" },
@@ -67,12 +71,12 @@ invoices_doc = MyData::Resources::Inv::InvoicesDoc.new(invoice: [invoice_data])
67
71
  client.send_invoices(doc: invoices_doc.to_xml)
68
72
  ```
69
73
 
70
- ##### Request transmitted docs
74
+ #### Request transmitted docs
71
75
  ```ruby
72
76
  client.request_transmitted_docs(mark: 1)
73
77
  ```
74
78
 
75
- ##### Cancel Invoice
79
+ #### Cancel Invoice
76
80
  ```ruby
77
81
  client.cancel_invoice(mark: 400001831924171)
78
82
  ```
@@ -2,11 +2,15 @@
2
2
 
3
3
  module MyData
4
4
  class Client
5
- BASE_URL = "https://mydata-dev.azure-api.net"
5
+ BASE_URL = {
6
+ sandbox: "https://mydata-dev.azure-api.net",
7
+ production: "https://mydatapi.aade.gr/myDATA/"
8
+ }.freeze
6
9
 
7
- def initialize(user_id:, subscription_key:)
10
+ def initialize(user_id:, subscription_key:, environment:)
8
11
  @user_id = user_id
9
12
  @subscription_key = subscription_key
13
+ @environment = environment
10
14
  end
11
15
 
12
16
  def send_invoices(doc:)
@@ -19,13 +23,21 @@ module MyData
19
23
  )
20
24
  end
21
25
 
22
- def request_transmitted_docs(mark:)
23
- response = connection.get("RequestTransmittedDocs", mark: mark)
26
+ def request_docs(mark:, next_partition_key: nil, next_row_key: nil)
27
+ base_request_docs(
28
+ endpoint: "RequestDocs",
29
+ mark: mark,
30
+ next_partition_key: next_partition_key,
31
+ next_row_key: next_row_key
32
+ )
33
+ end
24
34
 
25
- parse_response(
26
- response,
27
- resource: MyData::Resources::Inv::RequestDoc,
28
- root: "requested_doc"
35
+ def request_transmitted_docs(mark:, next_partition_key: nil, next_row_key: nil)
36
+ base_request_docs(
37
+ endpoint: "RequestTransmittedDocs",
38
+ mark: mark,
39
+ next_partition_key: next_partition_key,
40
+ next_row_key: next_row_key
29
41
  )
30
42
  end
31
43
 
@@ -43,8 +55,24 @@ module MyData
43
55
 
44
56
  private
45
57
 
58
+ def base_request_docs(endpoint:, mark:, next_partition_key:, next_row_key:)
59
+ params = { mark: mark }
60
+
61
+ if next_partition_key && next_row_key
62
+ params.merge!(nextPartitionKey: next_partition_key, nextRowKey: next_row_key)
63
+ end
64
+
65
+ response = connection.get(endpoint, params)
66
+
67
+ parse_response(
68
+ response,
69
+ resource: MyData::Resources::Inv::RequestDoc,
70
+ root: "requested_doc"
71
+ )
72
+ end
73
+
46
74
  def connection
47
- @connection ||= Faraday.new(BASE_URL) do |conn|
75
+ @connection ||= Faraday.new(BASE_URL[@environment]) do |conn|
48
76
  conn.headers = headers
49
77
  end
50
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyData
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
data/my_data.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Api client for AADE myData"
13
13
  spec.homepage = "https://github.com/mikezaby/my_data"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michalis Zamparas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-20 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
- version: 2.4.0
164
+ version: 2.5.0
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="