shiprocket_api 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -14
- data/Guardfile +70 -0
- data/lib/shiprocket_api.rb +4 -1
- data/lib/shiprocket_api/resources/base.rb +2 -2
- data/lib/shiprocket_api/resources/label.rb +11 -0
- data/lib/shiprocket_api/resources/pickup.rb +13 -0
- data/lib/shiprocket_api/resources/pickup_location.rb +6 -2
- data/lib/shiprocket_api/resources/return_order.rb +62 -0
- data/lib/shiprocket_api/resources/return_order/awb.rb +18 -0
- data/lib/shiprocket_api/resources/tracking.rb +1 -1
- data/lib/shiprocket_api/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb80e6dbab753e93c12f9f7462baa642e2a763b48cc258b43f4dbbe042b5a2de
|
4
|
+
data.tar.gz: ea6cc57e1e4ba40e2ba5d0d5ef89e73c7e1c1f0e72fe9345b4ff16938b70f937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 578afff71f025a764908c8cb17b3c0ebd555fbc07da7608ca2d36e505af110c1bd5e9e4ae241de22d2beb085343da75b084e81315797dc67f0744e93107293a1
|
7
|
+
data.tar.gz: 4ead61bceabe11e509c3c2e4a89565833bcb9155cacf65cd30e077e790e04fc4787b32d1de33ac882fc7d5137b411c54507505a567e2189ce231b4b340ea9fc4
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shiprocket_api (0.3.
|
4
|
+
shiprocket_api (0.3.1)
|
5
5
|
activeresource (~> 5.0)
|
6
6
|
http
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (6.0
|
12
|
-
activesupport (= 6.0
|
11
|
+
activemodel (6.1.0)
|
12
|
+
activesupport (= 6.1.0)
|
13
13
|
activemodel-serializers-xml (1.0.2)
|
14
14
|
activemodel (> 5.x)
|
15
15
|
activesupport (> 5.x)
|
@@ -18,12 +18,12 @@ GEM
|
|
18
18
|
activemodel (>= 5.0, < 7)
|
19
19
|
activemodel-serializers-xml (~> 1.0)
|
20
20
|
activesupport (>= 5.0, < 7)
|
21
|
-
activesupport (6.0
|
21
|
+
activesupport (6.1.0)
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
|
-
i18n (>=
|
24
|
-
minitest (
|
25
|
-
tzinfo (~>
|
26
|
-
zeitwerk (~> 2.
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
minitest (>= 5.1)
|
25
|
+
tzinfo (~> 2.0)
|
26
|
+
zeitwerk (~> 2.3)
|
27
27
|
addressable (2.7.0)
|
28
28
|
public_suffix (>= 2.0.2, < 5.0)
|
29
29
|
builder (3.2.4)
|
@@ -61,8 +61,8 @@ GEM
|
|
61
61
|
http-cookie (1.0.3)
|
62
62
|
domain_name (~> 0.5)
|
63
63
|
http-form_data (2.3.0)
|
64
|
-
http-parser (1.2.
|
65
|
-
ffi-compiler
|
64
|
+
http-parser (1.2.2)
|
65
|
+
ffi-compiler
|
66
66
|
i18n (1.8.5)
|
67
67
|
concurrent-ruby (~> 1.0)
|
68
68
|
listen (3.2.1)
|
@@ -101,13 +101,12 @@ GEM
|
|
101
101
|
rspec-support (3.9.3)
|
102
102
|
shellany (0.0.1)
|
103
103
|
thor (1.0.1)
|
104
|
-
|
105
|
-
|
106
|
-
thread_safe (~> 0.1)
|
104
|
+
tzinfo (2.0.3)
|
105
|
+
concurrent-ruby (~> 1.0)
|
107
106
|
unf (0.1.4)
|
108
107
|
unf_ext
|
109
108
|
unf_ext (0.0.7.7)
|
110
|
-
zeitwerk (2.4.
|
109
|
+
zeitwerk (2.4.2)
|
111
110
|
|
112
111
|
PLATFORMS
|
113
112
|
ruby
|
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/lib/shiprocket_api.rb
CHANGED
@@ -17,5 +17,8 @@ module ShiprocketAPI
|
|
17
17
|
require 'shiprocket_api/resources/channel'
|
18
18
|
require 'shiprocket_api/resources/courier_serviceability'
|
19
19
|
require 'shiprocket_api/resources/tracking'
|
20
|
-
|
20
|
+
require 'shiprocket_api/resources/label'
|
21
|
+
require 'shiprocket_api/resources/pickup'
|
22
|
+
require 'shiprocket_api/resources/return_order/awb'
|
23
|
+
require 'shiprocket_api/resources/return_order'
|
21
24
|
end
|
@@ -29,9 +29,9 @@ module ShiprocketAPI
|
|
29
29
|
clear_session
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def set_prefix(prefix)
|
33
33
|
ori_prefix = self.prefix
|
34
|
-
self.prefix =
|
34
|
+
self.prefix = prefix
|
35
35
|
result = yield
|
36
36
|
self.prefix = ori_prefix
|
37
37
|
result
|
@@ -26,7 +26,7 @@ module ShiprocketAPI
|
|
26
26
|
class << self
|
27
27
|
|
28
28
|
def set_prefix_to_list_all_locations
|
29
|
-
|
29
|
+
set_prefix("#{Base.prefix}/settings/company/pickup") do
|
30
30
|
yield
|
31
31
|
end
|
32
32
|
end
|
@@ -45,6 +45,10 @@ module ShiprocketAPI
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
def id_from_response(response)
|
49
|
+
JSON.parse(response.body).dig("address", "id")
|
50
|
+
rescue JSON::ParserError
|
51
|
+
nil
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module ShiprocketAPI
|
2
|
+
class ReturnOrder < Base
|
3
|
+
self.prefix += "/orders/create/return"
|
4
|
+
self.element_name= ""
|
5
|
+
|
6
|
+
DEFAULT_ATTRS = {
|
7
|
+
order_id: "",
|
8
|
+
order_date: "",
|
9
|
+
channel_id: "",
|
10
|
+
pickup_customer_name: "",
|
11
|
+
pickup_last_name: "",
|
12
|
+
pickup_address: "",
|
13
|
+
pickup_address_2: "",
|
14
|
+
pickup_city: "",
|
15
|
+
pickup_state: "",
|
16
|
+
pickup_country: "",
|
17
|
+
pickup_pincode: "",
|
18
|
+
pickup_email: "",
|
19
|
+
pickup_phone: "",
|
20
|
+
pickup_isd_code: "",
|
21
|
+
pickup_location_id: "",
|
22
|
+
shipping_customer_name: "",
|
23
|
+
shipping_last_name: "",
|
24
|
+
shipping_address: "",
|
25
|
+
shipping_address_2: "",
|
26
|
+
shipping_city: "",
|
27
|
+
shipping_country: "",
|
28
|
+
shipping_pincode: "",
|
29
|
+
shipping_state: "",
|
30
|
+
shipping_email: "",
|
31
|
+
shipping_isd_code: "",
|
32
|
+
shipping_phone: "",
|
33
|
+
order_items: [
|
34
|
+
ShiprocketAPI::OrderItem.new
|
35
|
+
],
|
36
|
+
payment_method: "",
|
37
|
+
total_discount: "",
|
38
|
+
sub_total: "",
|
39
|
+
length: "",
|
40
|
+
breadth: "",
|
41
|
+
height: "",
|
42
|
+
weight: ""
|
43
|
+
}
|
44
|
+
|
45
|
+
def generate_awb(courier_id:)
|
46
|
+
self.awb = Awb.create(
|
47
|
+
shipment_id: shipment_id,
|
48
|
+
courier_id: courier_id,
|
49
|
+
is_return: 1
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_pickup(courier_id:)
|
54
|
+
self.pickup = Pickup.create(
|
55
|
+
shipment_id: shipment_id,
|
56
|
+
courier_id: courier_id,
|
57
|
+
is_return: 1
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ShiprocketAPI
|
2
|
+
class ReturnOrder::Awb < Base
|
3
|
+
self.prefix += "/courier/assign/awb"
|
4
|
+
self.element_name= ""
|
5
|
+
|
6
|
+
DEFAULT_ATTRS = {
|
7
|
+
shipment_id: 0,
|
8
|
+
courier_id: 0,
|
9
|
+
is_return: 1
|
10
|
+
}
|
11
|
+
|
12
|
+
def generate_label
|
13
|
+
return false unless self.attributes.shipment_id != 0
|
14
|
+
|
15
|
+
self.label= ::ShiprocketAPI::Label.create([shipment_id])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shiprocket_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Chong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- CODE_OF_CONDUCT.md
|
122
122
|
- Gemfile
|
123
123
|
- Gemfile.lock
|
124
|
+
- Guardfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|
126
127
|
- Rakefile
|
@@ -137,8 +138,12 @@ files:
|
|
137
138
|
- lib/shiprocket_api/resources/courier_serviceability.rb
|
138
139
|
- lib/shiprocket_api/resources/custom_order.rb
|
139
140
|
- lib/shiprocket_api/resources/forward_shipment.rb
|
141
|
+
- lib/shiprocket_api/resources/label.rb
|
140
142
|
- lib/shiprocket_api/resources/order_item.rb
|
143
|
+
- lib/shiprocket_api/resources/pickup.rb
|
141
144
|
- lib/shiprocket_api/resources/pickup_location.rb
|
145
|
+
- lib/shiprocket_api/resources/return_order.rb
|
146
|
+
- lib/shiprocket_api/resources/return_order/awb.rb
|
142
147
|
- lib/shiprocket_api/resources/session.rb
|
143
148
|
- lib/shiprocket_api/resources/tracking.rb
|
144
149
|
- lib/shiprocket_api/version.rb
|