postal_transfers_pl 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbaa03c192cce6ea0b25e8eba1e177f852116feff73da78437a1532ef9ebfdde
4
- data.tar.gz: 906fc7854a13c2c5b14db0e0d6c21e5504d0196816f77858f7a8c3f4f568be46
3
+ metadata.gz: 3143af464824dda70c2a01d811512b1b092db8c79135c157dd4a0a6e0f528b45
4
+ data.tar.gz: aa949f4cd9c486ff1a98a36a71e9df24b532f11fbdf21fe153a9f4e69368dd72
5
5
  SHA512:
6
- metadata.gz: 045dd673ca0c50d8c01349f5f86eba874109e4598ea41b312e3f6a65a73b4afb92599619a031f5ec4968da87ec554356f4b46c191effbcf1daef1221acd25a9b
7
- data.tar.gz: 2ee92b0cb56f6887daea5ba2d55ea0fffcfd62d7bea2572543a52644d35114a64907e371f2867f9b7b16bfbd96e9045851c5f67a27cc4eb503913972bc5d9003
6
+ metadata.gz: a4fee413acb5155bbcbcfa1edad60eff33b7902d0157de3059544f63f7cd2bd8b80cfd1d14ce9ba0bd09ead2d128176abd4dc16dbd06fd67df90a54d397bc787
7
+ data.tar.gz: 4e9c3842b2d8d0264d843d2e43e6b3027b53fb280f62bb9ae5d21921a033d150a42e71b4ac4e2d562df58c6c42c769c83c3f7b4f48a8fba19352a27203281373
data/README.md CHANGED
@@ -27,11 +27,11 @@ And then execute:
27
27
  Or install it yourself as:
28
28
 
29
29
  $ gem install postal_transfers_pl
30
-
30
+
31
31
  When bundled, set up a initializer to provide CLIENT CREDENTIALS
32
32
 
33
33
  Simply create a polish_post_pl.rb file in the initializers directory, and set it up like this:
34
-
34
+
35
35
  ```ruby
36
36
  PostalTransfersPl::Client.configure do |c|
37
37
  c.wsdl = ENV['PTP_WSDL'] - 'the wsdl address'
@@ -48,6 +48,7 @@ PostalTransfersPl::Client.configure do |c|
48
48
  c.list_documents = ENV['PTP_LIST_DOCUMENTS'] - 'the SOAP method to list all generated documents aside order (needed if failed to create) (string converted to symbol in gem)'
49
49
  c.read_document = ENV['PTP_READ_DOCUMENT'] - 'the SOAP method to read generated document regarding csv file errors for order (needed if failed to create) (string converted to symbol in gem)'
50
50
  c.ssl_version = ENV['PTP_SSL_VERSION'] - 'the version of TLS used by server You are connecting to'
51
+ c.file_name_regexp = ENV['PTP_FILE_NAME_REGEXP'] - 'file_name_regexp default: \d{6}_\d{6}_\D{4,} if for example using a temp storage before upload, it will convert name to required by api format'
51
52
  end
52
53
  ```
53
54
  If no initializer is provided exception will be raised. In this example I store all my credentialsin env variables.
@@ -75,7 +76,7 @@ example success response :
75
76
 
76
77
  ```ruby
77
78
  PostalTransfersPl::Client.payment_tracking(id: 'uip')
78
- ```
79
+ ```
79
80
  example success response :
80
81
  ```ruby
81
82
  {
@@ -83,7 +84,7 @@ example success response :
83
84
  :stan=>"BrakWplaty",
84
85
  :"@xmlns:i"=>"http://www.w3.org/2001/XMLSchema-instance"
85
86
  }
86
- ```
87
+ ```
87
88
  example partialy failed response - the tracking was triggered too early ( order in creation in the api )
88
89
  Easy to fix just rerun the method in a couple of minutes ;)
89
90
  ```ruby
@@ -91,11 +92,11 @@ Easy to fix just rerun the method in a couple of minutes ;)
91
92
  :stan=>"BrakPakietu",
92
93
  :"@xmlns:i"=>"http://www.w3.org/2001/XMLSchema-instance"
93
94
  }
94
- ```
95
+ ```
95
96
 
96
97
  ```ruby
97
98
  PostalTransfersPl::Client.create_mass_order(service_name: 'PPE', file_path: 'path to file / or url', auto_approve: false)
98
- ```
99
+ ```
99
100
  example success response :
100
101
  ```ruby
101
102
  {
@@ -113,13 +114,13 @@ example success response :
113
114
  :wartosc_przekazow_poprawnych=>"46.82",
114
115
  :"@xmlns:i"=>"http://www.w3.org/2001/XMLSchema-instance"
115
116
  }
116
- ```
117
+ ```
117
118
  example fail response for creation - when file is bad, parsed from error report file from the api side
118
119
  ```ruby
119
- {
120
- error: "\r\n Raport Kontroli Formalnej\r\n\r\nNazwa pliku: 181231_123055_useraaa.csv \r\nGrupa kontrahent\xF3w: R\xF3\xBFne \r\nKontrahent: XXXXXXX Sp.z o.o. Numer: 0000001757\r\nWynik kontroli: Plik niepoprawny\r\n-------------------------------------------------------------------------------\r\nStwierdzone b\xB3\xEAdy:\r\n\r\nOpis nag\xB3\xF3wka w linii 1:\r\n > Dla kolumny o nr 2/B jej opis powinien by\xE6 r\xF3wny Us\xB3uga\r\n\r\nData wygenerowania dokumentu 29-11-2018.\r\nDokument zosta\xB3 wygenerowany elektronicznie i nie wymaga podpisu ani stempla."
120
+ {
121
+ error: "\r\n Raport Kontroli Formalnej\r\n\r\nNazwa pliku: 181231_123055_useraaa.csv \r\nGrupa kontrahent\xF3w: R\xF3\xBFne \r\nKontrahent: XXXXXXX Sp.z o.o. Numer: 0000001757\r\nWynik kontroli: Plik niepoprawny\r\n-------------------------------------------------------------------------------\r\nStwierdzone b\xB3\xEAdy:\r\n\r\nOpis nag\xB3\xF3wka w linii 1:\r\n > Dla kolumny o nr 2/B jej opis powinien by\xE6 r\xF3wny Us\xB3uga\r\n\r\nData wygenerowania dokumentu 29-11-2018.\r\nDokument zosta\xB3 wygenerowany elektronicznie i nie wymaga podpisu ani stempla."
121
122
  }
122
- ```
123
+ ```
123
124
 
124
125
  example fail responses - most cases:
125
126
 
@@ -134,17 +135,17 @@ invalid file when creating or http errors
134
135
  Savon::SOAPFault || Savon::HTTPError
135
136
  ```
136
137
 
137
- ALL other methods come with a simple hash response or raise one of the common errors.
138
+ ALL other methods come with a simple hash response or raise one of the common errors.
138
139
 
139
140
  ## Development
140
141
 
141
- run rspec for tests.
142
+ run rspec for tests.
142
143
 
143
144
  ## Contributing
144
145
 
145
146
  Bug reports and pull requests are welcome on GitHub at https://github.com/justcodeio/postal_transfers_pl.
146
147
  This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
147
- Feel free to fork and expand it to Your needs !
148
+ Feel free to fork and expand it to Your needs !
148
149
 
149
150
  ## License
150
151
 
@@ -1,3 +1,3 @@
1
1
  module PostalTransfersPl
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -19,7 +19,7 @@ module PostalTransfersPl
19
19
  :list_documents, :read_document,
20
20
  :payment_tracking_trigger, :payment_tracking,
21
21
  :user, :password, :track, :create,
22
- :delete, :confirm, :ssl_version
22
+ :delete, :confirm, :ssl_version, :file_name_regexp
23
23
 
24
24
  def initialize
25
25
  @wsdl = nil
@@ -36,6 +36,7 @@ module PostalTransfersPl
36
36
  @list_documents = nil
37
37
  @read_document = nil
38
38
  @ssl_version = nil
39
+ @file_name_regexp = nil
39
40
  end
40
41
  end
41
42
 
@@ -70,10 +71,11 @@ module PostalTransfersPl
70
71
 
71
72
  def self.create_mass_order(service_name:, file_path:, auto_approve: false)
72
73
  file_name = File.basename(URI.parse(file_path).path)
74
+ api_file_name = Regexp.new(PostalTransfersPl::Client.configuration.file_name_regexp.to_s).match(file_name).to_s + '.csv'
73
75
  base = Base64.encode64(open(file_path).read)
74
76
  resp = self.new.client.call(
75
77
  PostalTransfersPl::Client.configuration.create.to_sym,
76
- message: { 'v1:RodzajUslugi' => service_name, 'v1:NazwaPliku' => file_name, 'v1:ZawartoscPliku' => base, 'v1:ZatwierdzenieAutomatyczne' => auto_approve }
78
+ message: { 'v1:RodzajUslugi' => service_name, 'v1:NazwaPliku' => api_file_name, 'v1:ZawartoscPliku' => base, 'v1:ZatwierdzenieAutomatyczne' => auto_approve }
77
79
  ).to_hash.fetch((PostalTransfersPl::Client.configuration.create.to_s + '_response').to_sym)
78
80
  self.confirm_or_destroy_mass_order(id: resp.fetch(:uip))
79
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postal_transfers_pl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Stybel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-12-10 00:00:00.000000000 Z
12
+ date: 2018-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler