visma_eaccounting 0.0.6 → 0.1.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: cddf0d722fea1c913468ad14eeb3269b2391b1a4f4a5c3ef21726c301b249627
4
- data.tar.gz: cddd485073e76261b98f20e2ef67d8730b6208ff19f8dce81538edf2347b36d1
3
+ metadata.gz: ec724f638b8217a764c65af420df7201f32d6102f21389364422859b1ed15285
4
+ data.tar.gz: 1a08f700903c91d477dbd854ac7658430c248942645477958b0a98588b5faf52
5
5
  SHA512:
6
- metadata.gz: fab8e77ad40b4e704112c289cfd607b7e1819ed58679b3ad176029a8c13069722b4bab68626aa1e0f1a1f0fb54420052a12fc39c6fcd544b21793beb6c51163c
7
- data.tar.gz: 65a4863fa2cd059587cf94c0488f0cdf79849b2e190beec284e330f52bdc8008c0a88f495c7ce48de29343f1914421959763a6be82841edc5e4b4c6da70d8940
6
+ metadata.gz: 80b2de56b4584b4825312968ca1b32331408b04c2196b3008a0ddd95d1bbfe21620c178045f524f25e952bf863f9b121197c2499d3a232945054b03ad739328c
7
+ data.tar.gz: acc3fa7b2e7d51ca9ecec360110adf02434bc5a9a92ce023d47629325d2fc51204b0e15944879a083c5440692e15f2bf0a2bc6945be80d9b48006ceaa81b27d6
data/README.markdown CHANGED
@@ -46,11 +46,10 @@ visma_eaccounting.customers.retrieve(headers: {"SomeHeader": "SomeHeaderValue"},
46
46
 
47
47
  Of course, `body` is only supported on `create` and `update` calls. Those map to HTTP `POST` and `PUT` verbs respectively.
48
48
 
49
- You can set `token`, `api_environment`, `api_endpoint`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, and `debug` globally:
49
+ You can set `token`, `api_endpoint`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, and `debug` globally:
50
50
 
51
51
  ```ruby
52
52
  VismaEaccounting::Request.token = "your_token"
53
- VismaEaccounting::Request.api_environment = :sandbox
54
53
  VismaEaccounting::Request.timeout = 15
55
54
  VismaEaccounting::Request.open_timeout = 15
56
55
  VismaEaccounting::Request.symbolize_keys = true
@@ -75,10 +74,6 @@ visma_eaccounting = VismaEaccounting::Request.new(token: "your_token", symbolize
75
74
 
76
75
  Visma's [API documentation](https://developer.vismaonline.com/#APIReference) is a list of available endpoints.
77
76
 
78
- ## Environments
79
-
80
- The default environment is ```:production```. To use the sandbox environment you can set ```:sandbox``` in constructor or globally using the ```api_environment``` option. This will set the default ```api_endpoint``` URL.
81
-
82
77
  ## Debug Logging
83
78
 
84
79
  Pass `debug: true` to enable debug logging to STDOUT.
@@ -78,10 +78,6 @@ module VismaEaccounting
78
78
  @request_builder.token
79
79
  end
80
80
 
81
- def api_environment
82
- @request_builder.api_environment
83
- end
84
-
85
81
  def api_endpoint
86
82
  @request_builder.api_endpoint
87
83
  end
@@ -155,7 +151,7 @@ module VismaEaccounting
155
151
  if @request_builder.debug
156
152
  faraday.response :logger, @request_builder.logger, bodies: true
157
153
  end
158
- conn.request :authorization, 'Bearer', self.token
154
+ faraday.request :authorization, 'Bearer', self.token
159
155
  end
160
156
  end
161
157
 
@@ -189,12 +185,7 @@ module VismaEaccounting
189
185
  end
190
186
 
191
187
  def base_api_url
192
- case @request_builder.api_environment
193
- when :sandbox
194
- "https://eaccountingapi-sandbox.test.vismaonline.com/v2/"
195
- when :production
196
- "https://eaccountingapi.vismaonline.com/v2/"
197
- end
188
+ "https://eaccountingapi.vismaonline.com/v2/"
198
189
  end
199
190
  end
200
191
  end
@@ -1,16 +1,14 @@
1
1
  module VismaEaccounting
2
2
  class Request
3
- attr_accessor :token, :api_environment, :api_endpoint, :timeout, :open_timeout, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
3
+ attr_accessor :token, :api_endpoint, :timeout, :open_timeout, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
4
4
 
5
5
  DEFAULT_TIMEOUT = 60
6
6
  DEFAULT_OPEN_TIMEOUT = 60
7
- DEFAULT_API_ENVIRONMENT = :production
8
7
 
9
- def initialize(token: nil, api_environment: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil)
8
+ def initialize(token: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil)
10
9
  @path_parts = []
11
10
  @token = token || self.class.token
12
11
  @token = @token.strip if @token
13
- @api_environment = api_environment || self.class.api_environment || DEFAULT_API_ENVIRONMENT
14
12
  @api_endpoint = api_endpoint || self.class.api_endpoint
15
13
  @timeout = timeout || self.class.timeout || DEFAULT_TIMEOUT
16
14
  @open_timeout = open_timeout || self.class.open_timeout || DEFAULT_OPEN_TIMEOUT
@@ -76,10 +74,10 @@ module VismaEaccounting
76
74
  end
77
75
 
78
76
  class << self
79
- attr_accessor :token, :timeout, :open_timeout, :api_environment, :api_endpoint, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
77
+ attr_accessor :token, :timeout, :open_timeout, :api_endpoint, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger
80
78
 
81
79
  def method_missing(sym, *args, &block)
82
- new(token: self.token, api_environment: self.api_environment, api_endpoint: self.api_endpoint, timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter, symbolize_keys: self.symbolize_keys, debug: self.debug, proxy: self.proxy, logger: self.logger).send(sym, *args, &block)
80
+ new(token: self.token, api_endpoint: self.api_endpoint, timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter, symbolize_keys: self.symbolize_keys, debug: self.debug, proxy: self.proxy, logger: self.logger).send(sym, *args, &block)
83
81
  end
84
82
 
85
83
  def respond_to_missing?(method_name, include_private = false)
@@ -1,3 +1,3 @@
1
1
  module VismaEaccounting
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -116,35 +116,6 @@ describe VismaEaccounting do
116
116
  expect(@visma_eaccounting.logger).to be_a Logger
117
117
  end
118
118
 
119
- it "api_environment production by default" do
120
- @visma_eaccounting = VismaEaccounting::Request.new
121
- expect(@visma_eaccounting.api_environment).to be :production
122
- end
123
-
124
- it "sets api_environment in the constructor" do
125
- @visma_eaccounting = VismaEaccounting::Request.new(api_environment: :sandbox)
126
- expect(@visma_eaccounting.api_environment).to be :sandbox
127
- end
128
-
129
- end
130
-
131
- describe "supports different environments" do
132
- before do
133
- VismaEaccounting::APIRequest.send(:public, *VismaEaccounting::APIRequest.protected_instance_methods)
134
- end
135
-
136
- it "has correct api url for default production environment" do
137
- @visma_eaccounting = VismaEaccounting::Request.new()
138
- @request = VismaEaccounting::APIRequest.new(builder: @visma_eaccounting)
139
- expect(@request.send(:base_api_url)).to eq("https://eaccountingapi.vismaonline.com/v2/")
140
- end
141
-
142
- it "has correct api url when setting sandbox environment" do
143
- @visma_eaccounting = VismaEaccounting::Request.new(api_environment: :sandbox)
144
- @request = VismaEaccounting::APIRequest.new(builder: @visma_eaccounting)
145
- expect(@request.send(:base_api_url)).to eq("https://eaccountingapi-sandbox.test.vismaonline.com/v2/")
146
- end
147
-
148
119
  end
149
120
 
150
121
  describe "build api url" do
@@ -166,7 +137,6 @@ describe VismaEaccounting do
166
137
  before do
167
138
  VismaEaccounting::Request.token = "ifeaean8hfaeo8AUfenao(ea"
168
139
  VismaEaccounting::Request.timeout = 15
169
- VismaEaccounting::Request.api_environment = :sandbox
170
140
  VismaEaccounting::Request.api_endpoint = 'https://eaccountingapi.example.org/v1337/'
171
141
  VismaEaccounting::Request.logger = logger
172
142
  VismaEaccounting::Request.proxy = "http://1234.com"
@@ -178,7 +148,6 @@ describe VismaEaccounting do
178
148
  after do
179
149
  VismaEaccounting::Request.token = nil
180
150
  VismaEaccounting::Request.timeout = nil
181
- VismaEaccounting::Request.api_environment = nil
182
151
  VismaEaccounting::Request.api_endpoint = nil
183
152
  VismaEaccounting::Request.logger = nil
184
153
  VismaEaccounting::Request.proxy = nil
@@ -195,11 +164,6 @@ describe VismaEaccounting do
195
164
  expect(VismaEaccounting::Request.new.timeout).to eq(VismaEaccounting::Request.timeout)
196
165
  end
197
166
 
198
- it "set api_environment on new instances" do
199
- expect(VismaEaccounting::Request.api_environment).not_to be_nil
200
- expect(VismaEaccounting::Request.new.api_environment).to eq(VismaEaccounting::Request.api_environment)
201
- end
202
-
203
167
  it "set api_endpoint on new instances" do
204
168
  expect(VismaEaccounting::Request.api_endpoint).not_to be_nil
205
169
  expect(VismaEaccounting::Request.new.api_endpoint).to eq(VismaEaccounting::Request.api_endpoint)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visma_eaccounting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espen Antonsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-05 00:00:00.000000000 Z
12
+ date: 2024-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.5.5
129
+ rubygems_version: 3.5.14
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: A wrapper for Visma eAccounting API 2.0