unit-ruby 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/lib/unit-ruby/statement.rb +22 -0
- data/lib/unit-ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28b28032ddbe1492ec95f1d4c5cea1564d846a3f93896c777e2c6440b185a55a
|
4
|
+
data.tar.gz: 5bb4f8338d3fdef99579a9b5f197b3516ac775e817163925167d05359f490f5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1cd24b58f9732e3f9ec0b9bc17f099d168dca9f05de60c8caa7082c387ef3d50a8363af85afe8cf0b39cfcd25af433058d2020eb38bcf586c21ea4bac23ef2
|
7
|
+
data.tar.gz: 13d02249eb4a6f90bf059861c2b3890d2b4b48294ce89557818633b148ea5da584a92cf6dffb5627400c063475d2877ea5e932ab2c78d03d92a70e95014249e4
|
data/Gemfile.lock
CHANGED
data/lib/unit-ruby/statement.rb
CHANGED
@@ -4,6 +4,28 @@ module Unit
|
|
4
4
|
|
5
5
|
attribute :period, Types::String
|
6
6
|
|
7
|
+
def self.pdf_for(statement_id:, customer_id:)
|
8
|
+
url = base_url(statement_id, :pdf, customer_id)
|
9
|
+
statement_connection(url).get.body
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.html_for(statement_id:, customer_id:)
|
13
|
+
url = base_url(statement_id, :html, customer_id)
|
14
|
+
statement_connection(url).get.body
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.base_url(statement_id, response_type, customer_id)
|
18
|
+
"#{Unit::Connection.base_url}statements/#{statement_id}/#{response_type}" \
|
19
|
+
"?filter[customerId]=#{customer_id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.statement_connection(url)
|
23
|
+
# Establishing a new connection to avoid having to alter the existing connection to support pdf / html responses
|
24
|
+
Faraday.new(url) do |f|
|
25
|
+
f.headers['Authorization'] = "Bearer #{Unit::Connection.api_key}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
7
29
|
include ResourceOperations::List
|
8
30
|
end
|
9
31
|
end
|
data/lib/unit-ruby/version.rb
CHANGED