nova-api 1.4.5 → 1.4.7

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: d65ec275d59211def3addb948fd8eb041a9011c4f863475b4ae20814dc7697b2
4
- data.tar.gz: 6485592406ff923bf58094e2c6aaf82b7778c8cdbdecc4edff6b004615b808b3
3
+ metadata.gz: 6e777554aac2b980c831bfb55c95667c4ae3aedcf9c160ef44030b7e401f9e05
4
+ data.tar.gz: c7f07bf53191160beb9c472328dd7666052f97e6c533eda971a1ea43d8171076
5
5
  SHA512:
6
- metadata.gz: b0607c64dba8511a2b183982137e754c4401709dec523dcd8b72e4b1091a99b58b86459ecdee67ad7d6dd194ae515e640437ed0def9dd952d4c17ddf57637062
7
- data.tar.gz: 8f2ba32f43f95856e1afa04096db889980203d563eef690bdba54554f8536cb0b4aaffd05c3a187e7a685362e74c23ea22948866784cf9373fe8ffbc3d6f4c08
6
+ metadata.gz: 410f761cd84115bcc1e4b6e609e36d6926f6e5a6d304b804827bf1c250d587a7b6e8ebd038f9f60ff860b52a8f9f3cc12c47307c54c3cd29e15b73bbe86daecf
7
+ data.tar.gz: 47db08b4911fbd9327eac996c38ce4ae89c56223e2d8586f8e1a5ebd1f9843ad8953fe04a2dadc1b4dbb8ea8575b4d859233b6d17352a05092237da9143c5ab7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nova-api (1.4.5)
4
+ nova-api (1.4.7)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  httparty (~> 0.1)
data/lib/nova/api/base.rb CHANGED
@@ -4,10 +4,6 @@ require 'forwardable'
4
4
  module Nova
5
5
  module API
6
6
  class Base < Nova::API::Utils::BaseStruct
7
- include HTTParty
8
-
9
- format :json
10
-
11
7
  SCHEME = 'https'
12
8
  PRODUCTION_HOST = 'nova.money'
13
9
  STAGING_HOST = 'staging.nova.money'
@@ -23,6 +19,7 @@ module Nova
23
19
 
24
20
  "#{SCHEME}://#{configuration.subdomain}.#{host}"
25
21
  end
22
+ def_delegator self, :base_url
26
23
 
27
24
  def endpoint
28
25
  raise EndpointNotConfiguredError, 'Each class must implement its own endpoint'
@@ -31,53 +28,47 @@ module Nova
31
28
  protected
32
29
 
33
30
  def self.do_get_search(endpoint, query, object = self)
34
- response = perform_get(endpoint, query, headers)
31
+ response = perform_get(endpoint, query)
35
32
 
36
33
  Nova::API::ListResponse.build(response, object)
37
34
  end
38
35
 
39
36
  def self.do_get(endpoint, query, object = self)
40
- response = perform_get(endpoint, query, headers)
37
+ response = perform_get(endpoint, query)
41
38
 
42
39
  Nova::API::Response.build(response, object)
43
40
  end
44
41
  def_delegator self, :do_get
45
42
 
46
43
  def do_delete(endpoint)
47
- set_base_uri
48
-
49
- Kernel.p "[NOVA-API] Issuing DELETE to #{endpoint}, headers: #{authorization_header}" if configuration.debug?
44
+ Kernel.p "[NOVA-API] Issuing DELETE to #{base_url}#{endpoint}, headers: #{authorization_header}" if configuration.debug?
50
45
 
51
- response = self.class.delete(endpoint, headers: authorization_header)
46
+ response = HTTParty.delete("#{base_url}#{endpoint}", headers: authorization_header, format: :json)
52
47
 
53
48
  Nova::API::Response.build(response)
54
49
  end
55
50
 
56
51
  def do_patch(endpoint, data)
57
- set_base_uri
58
-
59
- Kernel.p "[NOVA-API] Issuing PATCH to #{endpoint}, headers: #{authorization_header}" if configuration.debug?
52
+ Kernel.p "[NOVA-API] Issuing PATCH to #{base_url}#{endpoint}, headers: #{authorization_header}" if configuration.debug?
60
53
 
61
54
  if data.nil? || data.empty?
62
- response = self.class.patch(endpoint, headers: authorization_header)
55
+ response = HTTParty.patch("#{base_url}#{endpoint}", headers: authorization_header, format: :json)
63
56
 
64
57
  Nova::API::Response.build(response)
65
58
  else
66
59
  payload = data.dup
67
60
  payload.delete(:id)
68
61
 
69
- response = self.class.patch(endpoint, body: payload, headers: authorization_header)
62
+ response = HTTParty.patch("#{base_url}#{endpoint}", body: payload, headers: authorization_header, format: :json)
70
63
 
71
64
  Nova::API::Response.build(response, self)
72
65
  end
73
66
  end
74
67
 
75
68
  def do_post(endpoint, data)
76
- set_base_uri
77
-
78
- Kernel.p "[NOVA-API] Issuing POST to #{endpoint}, headers: #{authorization_header}" if configuration.debug?
69
+ Kernel.p "[NOVA-API] Issuing POST to #{base_url}#{endpoint}, headers: #{authorization_header}" if configuration.debug?
79
70
 
80
- response = self.class.post(endpoint, body: data, headers: authorization_header)
71
+ response = HTTParty.post("#{base_url}#{endpoint}", body: data, headers: authorization_header, format: :json)
81
72
 
82
73
  Nova::API::Response.build(response, self)
83
74
  end
@@ -89,15 +80,13 @@ module Nova
89
80
  private
90
81
 
91
82
  def self.perform_get(endpoint, query, headers = {})
92
- set_base_uri
93
-
94
- Kernel.p "[NOVA-API] Issuing GET to #{endpoint}, headers: #{headers.merge(authorization_header)}" if configuration.debug?
83
+ Kernel.p "[NOVA-API] Issuing GET to #{base_url}#{endpoint}, headers: #{headers.merge(authorization_header)}" if configuration.debug?
95
84
 
96
85
  response =
97
86
  if query
98
- self.get(endpoint, query: query, headers: headers.merge(authorization_header))
87
+ HTTParty.get("#{base_url}#{endpoint}", query: query, headers: headers.merge(authorization_header), format: :json)
99
88
  else
100
- self.get(endpoint, headers: headers.merge(authorization_header))
89
+ HTTParty.get("#{base_url}#{endpoint}", headers: headers.merge(authorization_header), format: :json)
101
90
  end
102
91
  end
103
92
 
@@ -110,17 +99,6 @@ module Nova
110
99
  Nova::API.configuration
111
100
  end
112
101
  def_delegator self, :configuration
113
-
114
- def self.set_base_uri
115
- if configuration.debug?
116
- debug_output $stdout
117
-
118
- Kernel.p "[NOVA-API] Changing base URI from #{base_uri} to #{base_url}"
119
- end
120
-
121
- base_uri base_url
122
- end
123
- def_delegator self, :set_base_uri
124
102
  end
125
103
  end
126
104
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nova
4
4
  module API
5
- VERSION = '1.4.5'
5
+ VERSION = '1.4.7'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nova-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coyô Software
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler