xpensify-sdk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/LICENSE +21 -0
- data/README.md +9 -2
- data/lib/xpensify_sdk/client.rb +6 -0
- data/lib/xpensify_sdk/http_client.rb +9 -1
- data/lib/xpensify_sdk/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440f5c9e24c9c7072940fe6e495350f5d7cb3514a2380b9da75553a46db3730c
|
4
|
+
data.tar.gz: 2887c5fa900b867efd773d81176a049ae7655a7f960c1b55d4b55a8a64b8ff2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e70e3565397832c6ca3649f9dd2e2a5b13a688077a899c5111c0c4382928c67850961075c8cb0efc0ac1f869497bfa85b2fd9dcc1d6c224acd02af29a23474
|
7
|
+
data.tar.gz: ec74028328e4d46c544a6fc3d8e7e64be827c5d1719300821a76b9c5a4cfa3c4e604f3aba67fef5b4113530789cee22061c5cc19b6bcbe394e109f162007303d
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
xpensify-sdk (0.0.2)
|
5
5
|
http (~> 5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -91,7 +91,7 @@ DEPENDENCIES
|
|
91
91
|
rubocop-performance (~> 1.12)
|
92
92
|
rubocop-rspec (~> 2.6)
|
93
93
|
simplecov (~> 0.21)
|
94
|
-
|
94
|
+
xpensify-sdk!
|
95
95
|
|
96
96
|
BUNDLED WITH
|
97
97
|
2.2.31
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Xpensify
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ You can read the API docs directly from [here](https://xpensifyapi.docs.apiary.i
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'xpensify-sdk'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -21,7 +21,7 @@ $> bundle
|
|
21
21
|
Or install it yourself as:
|
22
22
|
|
23
23
|
```bash
|
24
|
-
$> gem install
|
24
|
+
$> gem install xpensify-sdk
|
25
25
|
```
|
26
26
|
|
27
27
|
## Usage
|
@@ -86,6 +86,13 @@ puts invoice.id
|
|
86
86
|
puts invoice.products
|
87
87
|
```
|
88
88
|
|
89
|
+
### Update an invoice
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
client = XpensifySDK::Client.new
|
93
|
+
client.update_invoice(ID, { accounted: 'completed' }) #=> :ok
|
94
|
+
```
|
95
|
+
|
89
96
|
### Errors
|
90
97
|
|
91
98
|
You can check [here](https://github.com/Xpensify/ruby-sdk/blob/master/lib/xpensify_sdk/error.rb) all the error classes that the library raises.
|
data/lib/xpensify_sdk/client.rb
CHANGED
@@ -16,5 +16,11 @@ module XpensifySDK
|
|
16
16
|
# TODO: use dry-rb structs instead of OpenStruct
|
17
17
|
JSON.parse(response.body.to_s, object_class: OpenStruct) # rubocop:disable Style/OpenStructUse
|
18
18
|
end
|
19
|
+
|
20
|
+
def update_invoice(id, options)
|
21
|
+
response = HTTPClient.update_invoice(id, options, @api_key)
|
22
|
+
Error.raise_from_code!(response.code) if response.code != 200
|
23
|
+
:ok
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
@@ -20,10 +20,18 @@ module XpensifySDK
|
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
|
+
def update_invoice(id, params, api_key)
|
24
|
+
HTTP.put(
|
25
|
+
"#{API_URL}/invoices/#{id}",
|
26
|
+
body: params.to_json,
|
27
|
+
headers: build_headers(api_key)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
23
31
|
private
|
24
32
|
|
25
33
|
def build_headers(api_key)
|
26
|
-
{ 'Authorization' => api_key }
|
34
|
+
{ 'Authorization' => api_key, 'Content-type' => 'application/json' }
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
data/lib/xpensify_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xpensify-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Bezdjian
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- ".travis.yml"
|
68
68
|
- Gemfile
|
69
69
|
- Gemfile.lock
|
70
|
+
- LICENSE
|
70
71
|
- README.md
|
71
72
|
- Rakefile
|
72
73
|
- bin/console
|