visma_eaccounting 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a737f9498f23b71408ea0cb7354a4ab43f1a0d8857b45197264d2917a0a4bda8
4
- data.tar.gz: 53477ec8fd7db0e6e6d21bbcb8c99e2d210fcf280be63998edbf6f6426a31276
3
+ metadata.gz: 7856b9f01600c672d20af36217c68ac8f9fe49abef0d50793da416ee0f190e2a
4
+ data.tar.gz: 29ea3651d6d89bea0c422174c1e5151debf4d5a79837d5455c9380040b2fd42e
5
5
  SHA512:
6
- metadata.gz: 96c9e12c4139c153d476b980b8fe284b54529badab45f84887688e6a02d79f5db1433924f2217fba461a8981d243a514e7e7c51f6c2d5f82b234a5ef95e58ce4
7
- data.tar.gz: 753cd063742597f284bafcec09031e9ad1bda77816c6155599fcb8be4803f93352127390ff7019512e5ea6bb4ba03e14b2740e07de5846b8b9b2ffc8372c3df1
6
+ metadata.gz: 007fdcfc59f0e12b3d3f287f8becbfa683fddb63971cff508d792b7dcce4f25ae197b3510cdbac8af29a748d5db7fe1a001d8db9069597ddbf63bc0d1db09800
7
+ data.tar.gz: f16b78b08b8c1645d6c6c45090c62a5338b1cf9addfdc914af580e442003996c7f959f77342b4b65a479928d05e2975a7b6e1ecdb818e9c909594c6652909d5e
data/README.markdown CHANGED
@@ -10,9 +10,11 @@ VismaEaccounting returns a `VismaEaccounting::Response` instead of the response
10
10
 
11
11
  $ gem install visma_eaccounting
12
12
 
13
- ## Requirements
13
+ ## Authentication
14
14
 
15
- A Visma eAccounting account and oAuth client id.
15
+ The Visma eAccounting API authenticates using a token which you can retrieve when authorizating using OAuth with your Visma eAccounting account.
16
+
17
+ To retrieve an access token you can use [omniauth-visma](https://github.com/espen/omniauth-visma). Do note that this token expires in one hour so you need to fetch a new access token using the refresh token when required.
16
18
 
17
19
  ## Usage
18
20
 
@@ -114,7 +116,7 @@ By default the Visma API returns 50 results. To set the count to 50:
114
116
  visma_eaccounting.customers.retrieve(params: {"pagesize": "100"})
115
117
  ```
116
118
 
117
- And to retrieve the next 50 members:
119
+ And to retrieve the next 50 customers:
118
120
 
119
121
  ```ruby
120
122
  visma_eaccounting.customers.retrieve(params: {"pagesize": "100", "page": "2"})
@@ -155,7 +157,7 @@ available depending on the nature of the error. For example:
155
157
 
156
158
  ```ruby
157
159
  begin
158
- visma_eaccounting.customers(customer_id).members.create(body: body)
160
+ visma_eaccounting.customers.create(body: body)
159
161
  rescue VismaEaccounting::VismaEaccountingError => e
160
162
  puts "Houston, we have a problem: #{e.message} - #{e.raw_body}"
161
163
  end
@@ -182,7 +182,7 @@ module VismaEaccounting
182
182
  end
183
183
 
184
184
  def base_api_url
185
- case self.class.api_environment
185
+ case @request_builder.api_environment
186
186
  when :sandbox
187
187
  "https://eaccountingapi-sandbox.test.vismaonline.com/v2/"
188
188
  when :production
@@ -1,3 +1,3 @@
1
1
  module VismaEaccounting
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -6,7 +6,7 @@ describe VismaEaccounting::APIRequest do
6
6
 
7
7
  before do
8
8
  @visma_eaccounting = VismaEaccounting::Request.new(token: token)
9
- @api_root = "https://eaccountingapi-sandbox.test.vismaonline.com/v2"
9
+ @api_root = "https://eaccountingapi.vismaonline.com/v2/"
10
10
  end
11
11
 
12
12
  it "surfaces client request exceptions as a VismaEaccounting::APIError" do
@@ -14,6 +14,7 @@ describe VismaEaccounting do
14
14
  @visma_eaccounting = VismaEaccounting::Request.new
15
15
  expect(@visma_eaccounting.token).to be_nil
16
16
  end
17
+
17
18
  it "sets an API key in the constructor" do
18
19
  @visma_eaccounting = VismaEaccounting::Request.new(token: @token)
19
20
  expect(@visma_eaccounting.token).to eq(@token)
@@ -127,6 +128,25 @@ describe VismaEaccounting do
127
128
 
128
129
  end
129
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 corret 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
+ end
149
+
130
150
  describe "build api url" do
131
151
  before do
132
152
  VismaEaccounting::APIRequest.send(:public, *VismaEaccounting::APIRequest.protected_instance_methods)
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espen Antonsen