unit-ruby 0.9.0 → 0.10.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: 31e9eaeaa065486d11ffc46816fa19eaade6a1166527bafdc8cbb8dfd61a70b7
4
- data.tar.gz: c69bad898fa846d89c2e85410cad85ec0882b29e9af8894ece78739ad23e7f43
3
+ metadata.gz: e31b034179f13eb859547998eaba9d38df67c7becaea41ed14e23bfef35d4aa7
4
+ data.tar.gz: ff540f8d02f5fbe31096a0158dc4050c41830bb596c572986377339c406f462c
5
5
  SHA512:
6
- metadata.gz: 406e5c03c055199057c654a07187129ebc7c0a5479cf73de543f8b26733cef4d6e68e84de7ae5a10d6cc8bcb4675f7a8363d60a83693f316635f3a25ff06e8dc
7
- data.tar.gz: 8d1bf8879fa66866ffc9b0a88367799fe1c31c1f2ab8e48bc93c042631486b416ccb2f18155746a9519fa679db583b799f261ad550fb0967c5bbc2946b1093f1
6
+ metadata.gz: 2219dc5eb8680c78c08f3efee4e10aaa237507431b3c079ca6a9ba600e77a06928e8f5132cb9f5b094bc87afec643095c5dc3e47c6d330896283079fb0170945
7
+ data.tar.gz: 473e5f6ebc1e409a739a788792a64fceccd8c53fcbc07666d792bd9aa3e09e19a784260a516406466b30d8d72ea3f38b3918c1f2961c26da703d21f8f67e6432
@@ -16,6 +16,8 @@ on:
16
16
  env:
17
17
  UNIT_API_KEY: "${{secrets.UNIT_API_KEY}}"
18
18
  UNIT_BASE_URL: "${{secrets.UNIT_BASE_URL}}"
19
+ UNIT_THEME_ID: 55392
20
+ UNIT_LANGUAGE_ID: 14363
19
21
 
20
22
  jobs:
21
23
  test:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unit-ruby (0.9.0)
4
+ unit-ruby (0.10.0)
5
5
  activesupport
6
6
  faraday (>= 2.0.1, < 3)
7
7
  faraday-retry
@@ -56,6 +56,8 @@ GEM
56
56
  rspec-expectations (3.13.3)
57
57
  diff-lcs (>= 1.2.0, < 2.0)
58
58
  rspec-support (~> 3.13.0)
59
+ rspec-file_fixtures (0.1.9)
60
+ rspec (~> 3.12)
59
61
  rspec-mocks (3.13.2)
60
62
  diff-lcs (>= 1.2.0, < 2.0)
61
63
  rspec-support (~> 3.13.0)
@@ -85,6 +87,7 @@ DEPENDENCIES
85
87
  pry
86
88
  rake (~> 13.0)
87
89
  rspec (~> 3.0)
90
+ rspec-file_fixtures (~> 0.1.9)
88
91
  rubocop (~> 1.24.1)
89
92
  unit-ruby!
90
93
 
data/README.md CHANGED
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  ## Development
37
37
 
38
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You will also need UNIT_THEME_ID and UNIT_LANGUAGE_ID set in your environment. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
39
 
40
40
  To install this gem onto your local machine, run `bundle exec rake install`.
41
41
 
@@ -14,6 +14,7 @@ module Unit
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
+ f.headers['Content-Type'] = 'application/vnd.api+json'
17
18
  f.request :json # encode req bodies as JSON
18
19
  f.request :retry # retry transient failures
19
20
  f.response :json # decode response bodies as JSON
@@ -37,7 +38,6 @@ module Unit
37
38
  def post(path, data = nil)
38
39
  response = connection.post do |req|
39
40
  req.url path
40
- req.headers['Content-Type'] = 'application/vnd.api+json'
41
41
  req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
42
42
  end
43
43
 
@@ -50,7 +50,6 @@ module Unit
50
50
  def patch(path, data = nil)
51
51
  response = connection.patch do |req|
52
52
  req.url path
53
- req.headers['Content-Type'] = 'application/vnd.api+json'
54
53
  req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
55
54
  end
56
55
 
@@ -59,6 +58,15 @@ module Unit
59
58
  from_json_api(response.body)
60
59
  end
61
60
 
61
+ # Executes a PUT of a JSON object
62
+ def put(path, data = nil)
63
+ response = connection.put(path, data)
64
+
65
+ handle_errors(response)
66
+
67
+ from_json_api(response.body)
68
+ end
69
+
62
70
  def from_json_api(response_body)
63
71
  response_body.deep_transform_keys do |key|
64
72
  key.to_s.underscore.to_sym
@@ -77,5 +77,25 @@ module Unit
77
77
  update_resource_from_json_api(updated_resource)
78
78
  end
79
79
  end
80
+
81
+ # Replace the entire resource, instead of only patching dirty attributes
82
+ module Replace
83
+ def replace(attributes)
84
+ updated_resource = self.class.connection.put(
85
+ self.class.resource_path(id),
86
+ {
87
+ data: {
88
+ type: resource_type,
89
+ attributes: attributes
90
+ }
91
+ }
92
+ )
93
+ update_resource_from_json_api(updated_resource)
94
+ end
95
+
96
+ def replace_json(json_attributes)
97
+ replace(JSON.parse(json_attributes))
98
+ end
99
+ end
80
100
  end
81
101
  end
@@ -1,3 +1,3 @@
1
1
  module Unit
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -0,0 +1,9 @@
1
+ module Unit
2
+ class WhiteLabelLanguage < APIResource
3
+ path '/white-label/language'
4
+
5
+ include ResourceOperations::List
6
+ include ResourceOperations::Find
7
+ include ResourceOperations::Replace
8
+ end
9
+ end
@@ -1,4 +1,9 @@
1
1
  module Unit
2
2
  class WhiteLabelTheme < APIResource
3
+ path '/white-label/theme'
4
+
5
+ include ResourceOperations::List
6
+ include ResourceOperations::Find
7
+ include ResourceOperations::Replace
3
8
  end
4
9
  end
data/lib/unit-ruby.rb CHANGED
@@ -44,6 +44,7 @@ require 'unit-ruby/statement'
44
44
  require 'unit-ruby/transaction'
45
45
  require 'unit-ruby/version'
46
46
  require 'unit-ruby/white_label_theme'
47
+ require 'unit-ruby/white_label_language'
47
48
 
48
49
  module Unit
49
50
  # Usage:
data/unit-ruby.gemspec CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency 'pry'
43
43
  spec.add_development_dependency 'rake', '~> 13.0'
44
44
  spec.add_development_dependency 'rspec', '~> 3.0'
45
+ spec.add_development_dependency 'rspec-file_fixtures', '~> 0.1.9'
45
46
  spec.add_development_dependency 'rubocop', '~> 1.24.1'
46
47
  spec.metadata['rubygems_mfa_required'] = 'true'
47
48
  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.9.0
4
+ version: 0.10.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: 2024-12-27 00:00:00.000000000 Z
12
+ date: 2025-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -115,6 +115,20 @@ dependencies:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3.0'
118
+ - !ruby/object:Gem::Dependency
119
+ name: rspec-file_fixtures
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.9
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.1.9
118
132
  - !ruby/object:Gem::Dependency
119
133
  name: rubocop
120
134
  requirement: !ruby/object:Gem::Requirement
@@ -196,6 +210,7 @@ files:
196
210
  - lib/unit-ruby/util/resource_operations.rb
197
211
  - lib/unit-ruby/util/schema.rb
198
212
  - lib/unit-ruby/version.rb
213
+ - lib/unit-ruby/white_label_language.rb
199
214
  - lib/unit-ruby/white_label_theme.rb
200
215
  - unit-ruby.gemspec
201
216
  homepage: https://github.com/retirable/unit-ruby
@@ -222,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
237
  - !ruby/object:Gem::Version
223
238
  version: '0'
224
239
  requirements: []
225
- rubygems_version: 3.5.23
240
+ rubygems_version: 3.2.3
226
241
  signing_key:
227
242
  specification_version: 4
228
243
  summary: A Ruby gem for communicating with the Unit API.