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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa587b106ef43cc6d8855b0743fee4759c9cf1637740271cab313f3b3838f07b
4
- data.tar.gz: 9a5b9e38834ea195abf6e4cb41ccb8435df23737a2c657dc5dcdb4fb8510cf76
3
+ metadata.gz: 28b28032ddbe1492ec95f1d4c5cea1564d846a3f93896c777e2c6440b185a55a
4
+ data.tar.gz: 5bb4f8338d3fdef99579a9b5f197b3516ac775e817163925167d05359f490f5b
5
5
  SHA512:
6
- metadata.gz: f0e1b3f46ee5ee71a50cb237ac68166db3bb7fa1889021799e67da881812b821f484f49c8ed1f6c73c64090fb4ed39a1811c3bf237ed0e4e19438dc2762cd6c0
7
- data.tar.gz: da42517ea3121fd29e09d89e0eb5249f3c0e98fd28d7ee8e9df7e7af87b66e9820ada30ffb212b1a60e32b7bd8525538be4bda1c5e574a3a0d94877a26d7dc3f
6
+ metadata.gz: 9b1cd24b58f9732e3f9ec0b9bc17f099d168dca9f05de60c8caa7082c387ef3d50a8363af85afe8cf0b39cfcd25af433058d2020eb38bcf586c21ea4bac23ef2
7
+ data.tar.gz: 13d02249eb4a6f90bf059861c2b3890d2b4b48294ce89557818633b148ea5da584a92cf6dffb5627400c063475d2877ea5e932ab2c78d03d92a70e95014249e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unit-ruby (0.1.2)
4
+ unit-ruby (0.1.3)
5
5
  faraday (~> 1.8.0)
6
6
 
7
7
  GEM
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Unit
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unit-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chloe Isacke