xero-api 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example_app.oauth2 +1 -0
- data/.gitignore +1 -0
- data/README.md +18 -17
- data/lib/xero/api/version.rb +1 -1
- data/lib/xero/api.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0fc58050e51ea774703378f3898262fbe5f7b86d40cf78eee2f34d1777d94da
|
4
|
+
data.tar.gz: ef52a7a96f80dc414840d1fc7067a89077837b2bec376dded13fa560518ed5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1c5d982a4fd25dffd4112d7a4ae7584b7f6a13e7e87fec305bc578a5a99e76db6be487664272f2e054bbfda11cd824fd36175d611dedefedfe8efc4e0e0246
|
7
|
+
data.tar.gz: 16c36a3e6a933e438558b2bcd41ba9e926794e2a57fb1362c5a1c054a1f61309f0cc8ea5a57f34174439fd79be0c37c93f3950866c3b89eacd2b05b9af15b092
|
data/.env.example_app.oauth2
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export XERO_API_OAUTH2_ACCESS_TOKEN=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
### Ruby client for the Xero API version 2.
|
4
4
|
- **Pure JSON-in / JSON-out.** No XML support.
|
5
|
-
- 4 main methods: **.get, .create, .update, and .delete
|
6
|
-
- No validation rules built into the gem. **Validation comes from API only**.
|
5
|
+
- 4 main methods: **.get, .create, .update, and .delete**.
|
6
|
+
- No validation rules built into the gem. **Validation comes from the API only**.
|
7
7
|
- Close to the metal experience.
|
8
8
|
- First class logging.
|
9
9
|
- Robust error handling.
|
@@ -25,12 +25,12 @@ For example, here are the total code line counts (of `.rb` files):
|
|
25
25
|
- waynerobinson/xeroizer => 6019
|
26
26
|
- xero-gateway/xero_gateway => 5545
|
27
27
|
|
28
|
-
## Ruby >= 2.
|
28
|
+
## Ruby >= 2.7.0 required
|
29
29
|
|
30
30
|
## Current Limitations
|
31
31
|
|
32
32
|
- Accounting API only.
|
33
|
-
- Only
|
33
|
+
- Only [Custom Connections](https://developer.xero.com/documentation/guides/oauth2/custom-connections) and OAuth2 are supported.
|
34
34
|
|
35
35
|
## Installation
|
36
36
|
|
@@ -52,11 +52,13 @@ Or install it yourself as:
|
|
52
52
|
## Initialize
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
require 'oauth2'
|
56
|
+
require 'xero/api'
|
57
|
+
|
58
|
+
client = OAuth2::Client.new(ENV['XERO_OAUTH2_CLIENT_ID'), ENV['XERO_OAUTH2_CLIENT_SECRET'], token_url: 'https://identity.xero.com/connect/token' )
|
59
|
+
client_credentials = client.client_credentials.get_token
|
60
|
+
|
61
|
+
api = Xero::Api.new(access_token: client_credentials.token)
|
60
62
|
```
|
61
63
|
|
62
64
|
## .get
|
@@ -87,8 +89,8 @@ See all the arguments for the [`.get` method](https://github.com/minimul/xero-ap
|
|
87
89
|
```ruby
|
88
90
|
payload = {
|
89
91
|
"Type": "ACCREC",
|
90
|
-
"Contact": {
|
91
|
-
"ContactID": "f477ad8d-44f2-4bb7-a99b-04f28681e849"
|
92
|
+
"Contact": {
|
93
|
+
"ContactID": "f477ad8d-44f2-4bb7-a99b-04f28681e849"
|
92
94
|
},
|
93
95
|
"DateString": api.standard_date(Time.utc(2009, 05, 27)),
|
94
96
|
"DueDateString": api.standard_date(Time.utc(2009, 06, 06)),
|
@@ -156,7 +158,7 @@ Xero::Api.logger = Rails.logger
|
|
156
158
|
### .upload_attachment
|
157
159
|
```ruby
|
158
160
|
file_name = 'connect_xero_button_blue_2x.png'
|
159
|
-
resp = api.upload_attachment(:invoices, id: '9eb7b996-4ac6-4cf8-8ee8-eb30d6e572e3',
|
161
|
+
resp = api.upload_attachment(:invoices, id: '9eb7b996-4ac6-4cf8-8ee8-eb30d6e572e3',
|
160
162
|
file_name: file_name, content_type: 'image/png',
|
161
163
|
attachment: "#{__dir__}/../../../example/public/#{file_name}")
|
162
164
|
```
|
@@ -177,13 +179,13 @@ Xero::Api.logger = Rails.logger
|
|
177
179
|
```
|
178
180
|
|
179
181
|
### Spin up an example
|
182
|
+
## THIS SECTION NEEDS TO UPDATED TO OAUTH2
|
180
183
|
|
181
184
|
1. Follow and do all in Step 1 from the [Getting Started Guide](https://developer.xero.com/documentation/getting-started/getting-started-guide).
|
182
185
|
1. `git clone git://github.com/minimul/xero-api && cd xero-api`
|
183
186
|
1. `bundle`
|
184
187
|
1. Create a `.env` file
|
185
|
-
1. `cp .env.example_app.
|
186
|
-
1. Edit the `.env` file values with `consumer_key` and `consumer_secret`.
|
188
|
+
1. `cp .env.example_app.oauth2 .env`
|
187
189
|
1. Start up the example app => `ruby example/oauth.rb`
|
188
190
|
1. In browser go to `http://localhost:9393`.
|
189
191
|
1. Use the `Connect to Xero` button to connect to your Xero account.
|
@@ -206,13 +208,12 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/minimu
|
|
206
208
|
- `git clone git://github.com/minimul/xero-api && cd xero-api`
|
207
209
|
- `bundle`
|
208
210
|
- Create a `.env` file
|
209
|
-
- `cp .env.example_app.
|
211
|
+
- `cp .env.example_app.oauth2 .env`
|
210
212
|
- `bundle exec rake`
|
211
213
|
|
212
214
|
#### Creating new specs or modifying existing spec that have been recorded using the VCR gem.
|
213
|
-
- All specs that require interaction with the API must be recorded against the Xero Demo Company.
|
215
|
+
- All specs that require interaction with the API must be recorded against the Xero Demo Company.
|
214
216
|
|
215
217
|
## License
|
216
218
|
|
217
219
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
218
|
-
|
data/lib/xero/api/version.rb
CHANGED
data/lib/xero/api.rb
CHANGED
@@ -24,7 +24,7 @@ module Xero
|
|
24
24
|
LOG_TAG = "[xero-api gem]"
|
25
25
|
|
26
26
|
def initialize(attributes = {})
|
27
|
-
raise Xero::Api::Error, "missing or blank keyword:
|
27
|
+
raise Xero::Api::Error, "missing or blank keyword: access_token" unless attributes.key?(:access_token) and !attributes[:access_token].nil?
|
28
28
|
attributes = default_attributes.merge!(attributes)
|
29
29
|
attributes.each do |attribute, value|
|
30
30
|
public_send("#{attribute}=", value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xero-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Pelczarski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
description:
|
181
|
+
description:
|
182
182
|
email:
|
183
183
|
- christian@minimul.com
|
184
184
|
executables: []
|
@@ -217,7 +217,7 @@ homepage: https://github.com/minimul/xero-api
|
|
217
217
|
licenses:
|
218
218
|
- MIT
|
219
219
|
metadata: {}
|
220
|
-
post_install_message:
|
220
|
+
post_install_message:
|
221
221
|
rdoc_options: []
|
222
222
|
require_paths:
|
223
223
|
- lib
|
@@ -232,8 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
232
|
- !ruby/object:Gem::Version
|
233
233
|
version: '0'
|
234
234
|
requirements: []
|
235
|
-
rubygems_version: 3.
|
236
|
-
signing_key:
|
235
|
+
rubygems_version: 3.2.22
|
236
|
+
signing_key:
|
237
237
|
specification_version: 4
|
238
238
|
summary: Ruby JSON-only client for Xero API.
|
239
239
|
test_files: []
|