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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f0763f79d9bfa582154f0511065141c5ed9286d
4
- data.tar.gz: 33d65dfb7c1a15d88e5f56d69059894cc9bda8a1
3
+ metadata.gz: 843b441b6e67b7ad9c6be9c722b65a13369e7317
4
+ data.tar.gz: 4bcb9e845d5bf494ed78e84cb042dda323c0379b
5
5
  SHA512:
6
- metadata.gz: 286839b00dea9846e13ac5a0c96df708b4f4c20ffc47fe9966cb873d98d1fcb03c5d020bd3fb7a71bd914913b0ca0ca323c475de44c9f1db3592ca58e9e41cd7
7
- data.tar.gz: 90d52878e728886af3881df921a86de436889347cb24cea3693a692dd5c48c2466e943a842bb5eff6c7b16b346226c8e2a15ff8ee613e818115dbbc56fdf7801
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
@@ -30,6 +30,11 @@ class Jet::Client
30
30
  def orders
31
31
  Orders.new(self)
32
32
  end
33
+
34
+ def returns
35
+ Returns.new(self)
36
+ end
33
37
  end
34
38
 
35
39
  require 'jet/client/orders'
40
+ require 'jet/client/returns'
@@ -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
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: flipstock@gmail.com
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