visma_eaccounting 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7856b9f01600c672d20af36217c68ac8f9fe49abef0d50793da416ee0f190e2a
|
4
|
+
data.tar.gz: 29ea3651d6d89bea0c422174c1e5151debf4d5a79837d5455c9380040b2fd42e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
##
|
13
|
+
## Authentication
|
14
14
|
|
15
|
-
|
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
|
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
|
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
|
@@ -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
|
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)
|