unit-ruby 0.10.1 → 0.11.0

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: 4771e47bafd526a9a832e0552b1cc67a2e49720a44d87c727e0d2de4b764f1bf
4
- data.tar.gz: d96d783374e42fb21168afd0bf86f809f8fc309de3f6e7a0a0cf7fe4f320ef05
3
+ metadata.gz: c552dd97ad1e21746d22f97e46f5285693476724b0a5f2505e7d1ef3d723b4e3
4
+ data.tar.gz: 9c8eb5e38a4a587a3e9c2f756466a182db3e2c497cd4a5e4d4feb6111159923a
5
5
  SHA512:
6
- metadata.gz: 3e531d141c243bcaf32b651523092c3f543ac7a610026210ac6e165a9018de635bf3408f57dc487a9f66c8044f9659dbb98fe891705820efa413376db9e3242c
7
- data.tar.gz: 1bbaa140de53f9350b48ac53c725b591054abac4427ef1ba6e16eff04b0000bca8357469dc1d91b30bc40e7a0ac7534bc5d46bbcb215360c91615c6668fe52a4
6
+ metadata.gz: 4b76a8dfe7b897b9841dc65576695ee2d56f15a348557955d6c92078ef9613ae2c0e4419b5b5cc051eaaa6ebf0bb8355e3865dffca4eae3f1723e06148ab2855
7
+ data.tar.gz: 8433d406c7a4f2cc489b37be7fb793f86868ff4ccd4c1f502aa4382bbde27661f4c899aed2f8f0427d0f3f2caa99aaeb89234be8d23dc594122ce0282eaef449
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unit-ruby (0.10.1)
4
+ unit-ruby (0.11.0)
5
5
  activesupport
6
6
  faraday (>= 2.0.1, < 3)
7
7
  faraday-retry
@@ -1,18 +1,22 @@
1
1
  module Unit
2
2
  class ApplicationForm < APIResource
3
3
  path '/application-forms'
4
+ header 'X-Accept-Version' => 'V2024_06'
4
5
 
5
6
  attribute :tags, Types::Hash # Optional
6
7
  attribute :allowed_application_types, Types::Array # Optional. Array of Individual, Business or SoleProprietorship.
7
8
  attribute :applicant_details, Types::ApplicationFormPrefill # Optional. Add data that is already known about the end-customer to be auto populated on the form.
8
9
  attribute :settings_override, Types::ApplicationFormSettingsOverride # Optional. Override disclosure URLs that were defined in the application form settings.
9
-
10
- attribute :stage, Types::String, readonly: true
11
- attribute :url, Types::String, readonly: true
10
+ attribute :idempotency_key, Types::String
12
11
 
13
12
  belongs_to :application, class_name: 'Unit::IndividualApplication'
14
13
 
14
+ def url
15
+ links[:related][:href]
16
+ end
17
+
15
18
  include ResourceOperations::Create
16
19
  include ResourceOperations::Find
20
+ include ResourceOperations::List
17
21
  end
18
22
  end
@@ -1,6 +1,6 @@
1
1
  module Unit
2
2
  class APIResource
3
- attr_accessor :id, :type, :raw_data
3
+ attr_accessor :id, :type, :raw_data, :links
4
4
 
5
5
  def initialize(attributes = {})
6
6
  clear_attributes!
@@ -14,7 +14,7 @@ module Unit
14
14
  # Creates a base http connection to the API
15
15
  #
16
16
  def self.connection
17
- @connection ||= Connection.new
17
+ @connection ||= Connection.new(headers)
18
18
  end
19
19
 
20
20
  # Defines the schema for a resource's attributes
@@ -66,6 +66,21 @@ module Unit
66
66
  @path = route
67
67
  end
68
68
 
69
+ # Sets resource-specific headers
70
+ #
71
+ # Usage:
72
+ # class Customer < Unit::Resource
73
+ # header 'X-Some-Header' => 'Header Value'
74
+ # end
75
+ def self.header(header_key_value_pair)
76
+ key, value = header_key_value_pair.first
77
+ headers[key] = value
78
+ end
79
+
80
+ def self.headers
81
+ @headers ||= {}
82
+ end
83
+
69
84
  def self.resource_path(id)
70
85
  "#{path}/#{id}"
71
86
  end
@@ -149,6 +164,7 @@ module Unit
149
164
  self.type = data[:type]
150
165
  self.raw_data = data
151
166
  self.relationships = data[:relationships]
167
+ self.links = data[:links]
152
168
 
153
169
  clear_attributes!
154
170
 
@@ -10,11 +10,12 @@ module Unit
10
10
 
11
11
  attr_reader :connection
12
12
 
13
- def initialize
13
+ def initialize(custom_headers = {})
14
14
  @connection = Faraday.new(self.class.base_url) do |f|
15
15
  f.headers['UNIT_TRUST_TOKEN'] = self.class.trust_token if self.class.trust_token
16
16
  f.headers['Authorization'] = "Bearer #{self.class.api_key}"
17
17
  f.headers['Content-Type'] = 'application/vnd.api+json'
18
+ f.headers.merge!(custom_headers)
18
19
  f.request :json # encode req bodies as JSON
19
20
  f.request :retry # retry transient failures
20
21
  f.response :json # decode response bodies as JSON
@@ -1,3 +1,3 @@
1
1
  module Unit
2
- VERSION = '0.10.1'
2
+ VERSION = '0.11.0'
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.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chloe Isacke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-02-11 00:00:00.000000000 Z
12
+ date: 2025-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport