comgate_ruby 0.8.3.1 → 0.8.3.5
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -0
- data/lib/comgate/api_caller.rb +14 -0
- data/lib/comgate/gateway.rb +16 -0
- data/lib/comgate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f974dd47d4d868539ed68baa2dd30b2d1d1539662efbc65d0cba6cac02d70763
|
4
|
+
data.tar.gz: f7f156db914822d28e05bf9805d496519782c29d3676f8c1d0cfa0d39f616f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec831f7322aba06e135929d991a25a9d3f69a80b3f4a2fe0d00ce10baceff8036705e0597c0ffde7b6af1cc0c7ca8f0e79f501a2997274f52ccb74f816536442
|
7
|
+
data.tar.gz: 74e759684ba0bfb42281b00849facf0527c69e79dcd55fedf146f8f632f273ba552505f09fd87965eb0f1bd07c42a46050d9da2eff9423d4142f11e8ddc77f12
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -117,6 +117,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
117
117
|
variable_symbol: "12345678"}
|
118
118
|
]
|
119
119
|
```
|
120
|
+
### Get zip file containing CSV files with transfers of day (much richer data then previous)
|
121
|
+
1) Call `gateway.download_zipped_csvs_of_transfers(date: time_as_date, output_file_path: path_to_download)`.
|
122
|
+
2) Unzip (at your own) file at `:path_to_download`. There can be several CSV files.
|
123
|
+
Example file can be found at `./test/fixtures/csvs.zip`.
|
120
124
|
|
121
125
|
## Parameters
|
122
126
|
Structure of parameters is unchanged across most of methods, but you can leave out unused keys. You will get error if You do not pass required key.
|
data/lib/comgate/api_caller.rb
CHANGED
@@ -123,6 +123,8 @@ module Comgate
|
|
123
123
|
when 302
|
124
124
|
response_location
|
125
125
|
when 200
|
126
|
+
return nil if response_content_type == :zip
|
127
|
+
|
126
128
|
decoded_response_body.is_a?(Hash) ? decoded_response_body["redirect"] : nil
|
127
129
|
end
|
128
130
|
end
|
@@ -173,6 +175,8 @@ module Comgate
|
|
173
175
|
URI.decode_www_form(response.body).to_h
|
174
176
|
when :json
|
175
177
|
JSON.parse(response.body)
|
178
|
+
when :zip
|
179
|
+
{ file: store_as_tmp_file(response.body, "zipfile.zip") }
|
176
180
|
end
|
177
181
|
end
|
178
182
|
|
@@ -209,9 +213,19 @@ module Comgate
|
|
209
213
|
:json
|
210
214
|
elsif rct.include?("form-urlencoded")
|
211
215
|
:url_encoded
|
216
|
+
elsif rct.include?("zip")
|
217
|
+
:zip
|
212
218
|
else
|
213
219
|
raise "Uncaptured content type: '#{rct}'"
|
214
220
|
end
|
215
221
|
end
|
222
|
+
|
223
|
+
def store_as_tmp_file(body, filename = "comgate")
|
224
|
+
file = Tempfile.new(filename)
|
225
|
+
file.binmode
|
226
|
+
file.write(body)
|
227
|
+
file.rewind
|
228
|
+
file
|
229
|
+
end
|
216
230
|
end
|
217
231
|
end
|
data/lib/comgate/gateway.rb
CHANGED
@@ -171,6 +171,22 @@ module Comgate
|
|
171
171
|
test_call: false)
|
172
172
|
end
|
173
173
|
|
174
|
+
def download_zipped_csvs_of_transfers(date:, output_file_path:)
|
175
|
+
date_str = date.strftime("%Y-%m-%d")
|
176
|
+
|
177
|
+
resp = make_call(url: "#{BASE_URL}/csvDownload",
|
178
|
+
payload: gateway_params.merge({ date: date_str }),
|
179
|
+
test_call: false)
|
180
|
+
|
181
|
+
tmp_file = resp.hash[:file]
|
182
|
+
File.write(output_file_path, tmp_file.read)
|
183
|
+
tmp_file.close
|
184
|
+
tmp_file.unlink
|
185
|
+
|
186
|
+
resp.hash = { file_path: output_file_path }
|
187
|
+
resp
|
188
|
+
end
|
189
|
+
|
174
190
|
private
|
175
191
|
|
176
192
|
attr_reader :payment_data
|
data/lib/comgate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comgate_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.3.
|
4
|
+
version: 0.8.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Mlčoch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|