ruby-jet 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +6 -0
- data/lib/jet/client.rb +5 -0
- data/lib/jet/client/returns.rb +67 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843b441b6e67b7ad9c6be9c722b65a13369e7317
|
4
|
+
data.tar.gz: 4bcb9e845d5bf494ed78e84cb042dda323c0379b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331bb7cc8587d6d3689b1880dd9f265a5ed18fb4e89e5342438a8d46e657c4214c549b2724812b6ad859b5dcf300977c110a7fbd3bf4c8e5d37625a42101915e
|
7
|
+
data.tar.gz: bfa437dd5e29a6635c9df7266c3211c994fdddec5f7f5b943b7e68ccddb2a1a0b66ebe8a04f6c02d299a7fb7f16387755a321c85df417c03c0396495922e61b2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jason Wells
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Ruby Jet
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/jasonwells/ruby-jet.svg)](https://travis-ci.org/jasonwells/ruby-jet)
|
4
|
+
[![Dependency Status](https://gemnasium.com/jasonwells/ruby-jet.svg)](https://gemnasium.com/jasonwells/ruby-jet)
|
5
|
+
|
6
|
+
[Jet API](https://developer.jet.com/) service calls implemented in Ruby.
|
data/lib/jet/client.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Jet::Client::Returns
|
5
|
+
|
6
|
+
STATUSES = {
|
7
|
+
jet_refunded: 'Jet refunded',
|
8
|
+
created: 'created',
|
9
|
+
inprogress: 'inprogress',
|
10
|
+
completed_by_merchant: 'completed by merchant',
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_returns(status = :created)
|
18
|
+
headers = @client.get_token
|
19
|
+
query_status = STATUSES[status]
|
20
|
+
response = RestClient.get("#{Jet::Client::API_URL}/returns/#{query_status}", headers)
|
21
|
+
if response.code == 200
|
22
|
+
JSON.parse(response.body)
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_return(return_url)
|
29
|
+
headers = @client.get_token
|
30
|
+
response = RestClient.get("#{Jet::Client::API_URL}#{return_url}", headers)
|
31
|
+
if response.code == 200
|
32
|
+
JSON.parse(response.body)
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_return_by_id(return_id)
|
39
|
+
headers = @client.get_token
|
40
|
+
response = RestClient.get("#{Jet::Client::API_URL}/returns/state/#{return_id}", headers)
|
41
|
+
if response.code == 200
|
42
|
+
JSON.parse(response.body)
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def acknowledge_return(return_id, body = {})
|
49
|
+
headers = @client.get_token
|
50
|
+
response = RestClient.put("#{Jet::Client::API_URL}/returns/#{return_id}/acknowledge", body.to_json, headers)
|
51
|
+
if response.code == 200
|
52
|
+
JSON.parse(response.body)
|
53
|
+
else
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def complete_return(return_id, body = {})
|
59
|
+
headers = @client.get_token
|
60
|
+
response = RestClient.put("#{Jet::Client::API_URL}/returns/#{return_id}/complete", body.to_json, headers)
|
61
|
+
if response.code == 200
|
62
|
+
JSON.parse(response.body)
|
63
|
+
else
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Wells
|
@@ -39,14 +39,18 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
41
|
description: Jet API service calls implemented in Ruby
|
42
|
-
email:
|
42
|
+
email:
|
43
|
+
- flipstock@gmail.com
|
43
44
|
executables: []
|
44
45
|
extensions: []
|
45
46
|
extra_rdoc_files: []
|
46
47
|
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
47
50
|
- lib/jet.rb
|
48
51
|
- lib/jet/client.rb
|
49
52
|
- lib/jet/client/orders.rb
|
53
|
+
- lib/jet/client/returns.rb
|
50
54
|
homepage: https://github.com/jasonwells/ruby-jet
|
51
55
|
licenses:
|
52
56
|
- MIT
|