unleashed 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -1
- data/CHANGELOG.md +0 -1
- data/CODE_OF_CONDUCT.md +0 -1
- data/LICENSE +0 -1
- data/LICENSE.txt +0 -1
- data/README.md +36 -2
- data/Rakefile +0 -1
- data/lib/unleashed/client.rb +4 -55
- data/lib/unleashed/configurable.rb +1 -0
- data/lib/unleashed/models/customer.rb +0 -1
- data/lib/unleashed/models/invoice.rb +6 -0
- data/lib/unleashed/resources/customer_resource.rb +14 -0
- data/lib/unleashed/resources/invoice_resource.rb +39 -0
- data/lib/unleashed/version.rb +1 -1
- data/unleashed.gemspec +0 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fecd731ad21c9865bf063762b3ef5a61b36a1a05a732939aabb1bc25c3f0113
|
4
|
+
data.tar.gz: 168ecfdb748724ef08bdc61fda96df7db734ff51998c13571a87f72ce59de1f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9200bb879c2838c675315f5adbe0ceffbcfa5ff6f11a10eede2c619f0f6ef254565625363c515fa5fd2609dc5ce9085d6935dbbd5a329712303224184b564e5
|
7
|
+
data.tar.gz: be8b6c15381094f97e42d59894519dd3b86c4587df0eec55d3a7347362945815fa0e6c1181fede9fc19653ec60c59f7504583d47ebaa010f8ec25bf4293257e6
|
data/.rspec
CHANGED
data/.ruby-version
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
data/LICENSE
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Before interacting with Unleashed API you need to sign up an account.
|
|
24
24
|
|
25
25
|
See [Unleashed API Documentation](https://apidocs.unleashedsoftware.com/) for more information.
|
26
26
|
|
27
|
-
###
|
27
|
+
### Setup environment variables
|
28
28
|
|
29
29
|
The client can be configured through environment variables.
|
30
30
|
|
@@ -45,9 +45,17 @@ The following parameters are configurable through the client:
|
|
45
45
|
* `:api_key` / `ENV['UNLEASHED_API_KEY']`: API KEY
|
46
46
|
* `:client_type_header` / `ENV['UNLEASHED_CLIENT_TYPE_HEADER']`: Client Type Header to use (default: 'API-Sandbox')
|
47
47
|
|
48
|
+
### Setup default Unleashed client from environment variables
|
49
|
+
|
50
|
+
Add file `unleashed.rb` to `config/initializers`
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Unleashed.setup
|
54
|
+
```
|
55
|
+
|
48
56
|
## 3. Usage
|
49
57
|
|
50
|
-
### Instantiate the Unleashed client
|
58
|
+
### Instantiate the Unleashed client manually
|
51
59
|
|
52
60
|
```ruby
|
53
61
|
options = { api_id: ENV['UNLEASHED_API_ID'], api_key: ENV['UNLEASHED_API_KEY'] }
|
@@ -68,6 +76,32 @@ client.customers.all
|
|
68
76
|
client.customers.find('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
|
69
77
|
```
|
70
78
|
|
79
|
+
#### Get the first customer
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
client.customers.first
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Get the last customer
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
client.customers.last
|
89
|
+
```
|
90
|
+
|
91
|
+
### Invoices
|
92
|
+
|
93
|
+
#### Get all invoices
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
client.invoices.all
|
97
|
+
```
|
98
|
+
|
99
|
+
#### Get an invoice
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
client.invoices.find('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
|
103
|
+
```
|
104
|
+
|
71
105
|
## 4. Contributing
|
72
106
|
|
73
107
|
1. Fork it [https://github.com/nnhansg/unleashed-ruby](https://github.com/nnhansg/unleashed-ruby)
|
data/Rakefile
CHANGED
data/lib/unleashed/client.rb
CHANGED
@@ -2,8 +2,10 @@ require_relative 'configurable'
|
|
2
2
|
require_relative 'error'
|
3
3
|
require_relative 'models/base_model'
|
4
4
|
require_relative 'models/customer'
|
5
|
+
require_relative 'models/invoice'
|
5
6
|
require_relative 'resources/base_resource'
|
6
7
|
require_relative 'resources/customer_resource'
|
8
|
+
require_relative 'resources/invoice_resource'
|
7
9
|
require 'json'
|
8
10
|
require 'faraday'
|
9
11
|
|
@@ -69,66 +71,13 @@ module Unleashed
|
|
69
71
|
response
|
70
72
|
end
|
71
73
|
|
72
|
-
# # Make a HTTP POST request
|
73
|
-
# #
|
74
|
-
# # @param url [String] The path, relative to {#api_endpoint}
|
75
|
-
# # @param parameters [Hash] Query params for request
|
76
|
-
# # @return [Faraday::Response]
|
77
|
-
# def post(url, parameters = {})
|
78
|
-
# response = connection.post do |req|
|
79
|
-
# req.url "#{api_endpoint}#{url}"
|
80
|
-
# req.headers['Content-Type'] = 'application/json'
|
81
|
-
# req.body = parameters.to_json
|
82
|
-
# end
|
83
|
-
# on_complete(response)
|
84
|
-
# response
|
85
|
-
# end
|
86
|
-
|
87
|
-
# # Make a HTTP PATCH request
|
88
|
-
# #
|
89
|
-
# # @param url [String] The path, relative to {#api_endpoint}
|
90
|
-
# # @param parameters [Hash] Query params for request
|
91
|
-
# # @return [Faraday::Response]
|
92
|
-
# def patch(url, parameters = {})
|
93
|
-
# response = connection.patch do |req|
|
94
|
-
# req.url "#{api_endpoint}#{url}"
|
95
|
-
# req.headers['Content-Type'] = 'application/json'
|
96
|
-
# req.body = parameters.to_json
|
97
|
-
# end
|
98
|
-
# on_complete(response)
|
99
|
-
# response
|
100
|
-
# end
|
101
|
-
|
102
|
-
# # Make a HTTP DELETE request
|
103
|
-
# #
|
104
|
-
# # @param url [String] The path, relative to {#api_endpoint}
|
105
|
-
# # @param parameters [Hash] Query params for request
|
106
|
-
# # @return [Faraday::Response]
|
107
|
-
# def delete(url, parameters = {})
|
108
|
-
# response = connection.delete do |req|
|
109
|
-
# req.url "#{api_endpoint}#{url}"
|
110
|
-
# req.headers['Content-Type'] = 'application/json'
|
111
|
-
# req.body = parameters.to_json
|
112
|
-
# end
|
113
|
-
# on_complete(response)
|
114
|
-
# response
|
115
|
-
# end
|
116
|
-
|
117
|
-
# Show details of your Platform.
|
118
|
-
#
|
119
|
-
# @see https://reference.Unleashed.com/#show-marketplace
|
120
|
-
#
|
121
|
-
# @return [Hash]
|
122
|
-
def marketplace
|
123
|
-
JSON.parse(get('marketplace').body)['marketplaces']
|
124
|
-
end
|
125
|
-
|
126
74
|
# Available resources for {Client}
|
127
75
|
#
|
128
76
|
# @return [Hash]
|
129
77
|
def self.resources
|
130
78
|
{
|
131
|
-
customers: CustomerResource
|
79
|
+
customers: CustomerResource,
|
80
|
+
invoices: InvoiceResource
|
132
81
|
}
|
133
82
|
end
|
134
83
|
|
@@ -34,5 +34,19 @@ module Unleashed
|
|
34
34
|
response = JSON.parse(@client.get("Customers/#{id}").body)
|
35
35
|
Unleashed::Customer.new(@client, response)
|
36
36
|
end
|
37
|
+
|
38
|
+
# Get a first customer in all
|
39
|
+
#
|
40
|
+
# @return [Unleashed::Customer]
|
41
|
+
def first
|
42
|
+
all.first
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get a last customer in all
|
46
|
+
#
|
47
|
+
# @return [Unleashed::Customer]
|
48
|
+
def last
|
49
|
+
all.last
|
50
|
+
end
|
37
51
|
end
|
38
52
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Unleashed
|
2
|
+
# Resource for the Invoices API
|
3
|
+
# The Invoices resource allows sales invoices to be listed and viewed.
|
4
|
+
# An individual sales invoice details can be viewed by appending its identifier
|
5
|
+
# (a GUID formatted as XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to the URI.
|
6
|
+
#
|
7
|
+
# @see https://apidocs.unleashedsoftware.com/Invoices
|
8
|
+
class InvoiceResource < BaseResource
|
9
|
+
def model
|
10
|
+
Unleashed::Invoice
|
11
|
+
end
|
12
|
+
|
13
|
+
# List all invoices
|
14
|
+
# /Invoices - also returns the first 200 invoices because page number 1 is the default.
|
15
|
+
#
|
16
|
+
# @param options [Hash] Optional options.
|
17
|
+
# @option options [Integer] :page_size Can ask for up to 200 invoices. default: 10
|
18
|
+
# @option options [Integer] :page Page index. default: 1
|
19
|
+
#
|
20
|
+
# @return [Array<Unleashed::Invoice>] List all invoices.
|
21
|
+
def all(options = { page: 1, page_size: 10 })
|
22
|
+
response = JSON.parse(@client.get('Invoices', options).body)
|
23
|
+
invoices = response.key?('Items') ? response['Items'] : []
|
24
|
+
invoices.map { |attributes| Unleashed::Invoice.new(@client, attributes) }
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get a single invoice
|
28
|
+
# /Invoices/E6E8163F-6911-40e9-B740-90E5A0A3A996 - returns details of a particular invoice.
|
29
|
+
#
|
30
|
+
# @param id [String] invoice ID.
|
31
|
+
#
|
32
|
+
# @return [Unleashed::Invoice]
|
33
|
+
def find(id)
|
34
|
+
response = JSON.parse(@client.get("Invoices/#{id}").body)
|
35
|
+
Unleashed::Invoice.new(@client, response)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/lib/unleashed/version.rb
CHANGED
data/unleashed.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unleashed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nhan Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -115,8 +115,10 @@ files:
|
|
115
115
|
- lib/unleashed/error.rb
|
116
116
|
- lib/unleashed/models/base_model.rb
|
117
117
|
- lib/unleashed/models/customer.rb
|
118
|
+
- lib/unleashed/models/invoice.rb
|
118
119
|
- lib/unleashed/resources/base_resource.rb
|
119
120
|
- lib/unleashed/resources/customer_resource.rb
|
121
|
+
- lib/unleashed/resources/invoice_resource.rb
|
120
122
|
- lib/unleashed/version.rb
|
121
123
|
- unleashed.gemspec
|
122
124
|
homepage: https://github.com/nnhansg/unleashed-ruby
|