shiprocket_api 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 122050eabae3accd1e92af9aa33f684b387d2b4e651ebf1f5128b0363a3169a7
4
- data.tar.gz: 655b4d1fac605f8ac5a7535cf1b8308a5dd1ad1b06992a3eda1f484b2787f050
3
+ metadata.gz: 30bfb2da1528a9aa32926bf70d3994bf1dcaca94e10d80456e70cee9877f6693
4
+ data.tar.gz: 641b677f8661394d9d23c883485edce06314e3ab918f104a75d52c66a8ce5885
5
5
  SHA512:
6
- metadata.gz: e7d35d6ec3ef05c2eb0959bc59d9bc4c521c6610db8157ccd77e44bc7865ded10ee81c9695035f6341285cf79b49a35dcb97f5116ac62ded34f574efc1ca7299
7
- data.tar.gz: 4f67afabbee20217ac0cd24194a18a41f11bfba91271af3972a74620a55cebc768992e02dbe5492134d15c2c3c62175b3d66350d3fd0fdaf838c0a0a9303628e
6
+ metadata.gz: 2a5aaeb431053c527f944491046c7e3d0aaa00792d7805707c3fa1018c3cd7edc5ed918badea5e39133aadd87a20eeb871a42ac94289ad60d381cfa38c7c3b3e
7
+ data.tar.gz: 84317f05d64897c3964ad59373fc769958456422b8deb53510e640c5eea6e58b5732ca5ba4f330b50ac39820f33cf4642ff70ccf9ed4acd9f9074bfbb565b2c4
@@ -15,4 +15,5 @@ module ShiprocketAPI
15
15
  require 'shiprocket_api/resources/pickup_location'
16
16
  require 'shiprocket_api/resources/channel'
17
17
  require 'shiprocket_api/resources/courier_serviceability'
18
+ require 'shiprocket_api/resources/tracking'
18
19
  end
@@ -20,6 +20,14 @@ module ShiprocketAPI
20
20
  self.session = nil
21
21
  self.connection.bearer_token = nil
22
22
  end
23
+
24
+ def set_resource(resource)
25
+ ori_prefix = self.prefix
26
+ self.prefix = self.prefix.split("/")[0..-2].append(resource).join("/")
27
+ result = yield
28
+ self.prefix = ori_prefix
29
+ result
30
+ end
23
31
  end
24
32
 
25
33
  def initialize(attributes = {}, persisted = false)
@@ -6,23 +6,23 @@ module ShiprocketAPI
6
6
  has_many :order_items, class_name: "ShiprocketAPI::OrderItem"
7
7
 
8
8
  DEFAULT_ATTRS = {
9
- order_id: "1235",
9
+ order_id: "",
10
10
  order_date: Date.today.strftime("%Y-%m-%d"),
11
- pickup_location: "test1",
11
+ pickup_location: "",
12
12
  channel_id: "",
13
13
  comment: "",
14
14
  reseller_name: "",
15
15
  company_name: "",
16
- billing_customer_name: "Andy Chong",
16
+ billing_customer_name: "",
17
17
  billing_last_name: "",
18
- billing_address: "Salarpuria Symbiosis, Arekere Village, Begur, Bannerghatta Main Rd, Uttarahalli Hobli",
18
+ billing_address: "",
19
19
  billing_address_2: "",
20
- billing_city: "Bengaluru",
21
- billing_pincode: "560076",
22
- billing_state: "Karnataka",
23
- billing_country: "India",
24
- billing_email: "andy@postco.co",
25
- billing_phone: 9223361686,
20
+ billing_city: "",
21
+ billing_pincode: "",
22
+ billing_state: "",
23
+ billing_country: "",
24
+ billing_email: "",
25
+ billing_phone: "",
26
26
  billing_alternate_phone: "",
27
27
  shipping_is_billing: true,
28
28
  shipping_customer_name: "",
@@ -41,11 +41,11 @@ module ShiprocketAPI
41
41
  giftwrap_charges: "",
42
42
  transaction_charges: "",
43
43
  total_discount: "",
44
- sub_total: 1000,
45
- length: 0.5,
46
- breadth: 0.5,
47
- height: 0.5,
48
- weight: 0.5,
44
+ sub_total: "",
45
+ length: "",
46
+ breadth: "",
47
+ height: "",
48
+ weight: "",
49
49
  ewaybill_no: "",
50
50
  customer_gstin: ""
51
51
  }
@@ -24,16 +24,15 @@ module ShiprocketAPI
24
24
  }
25
25
 
26
26
  class << self
27
- def set_prefix_to_list
28
- ori_prefix = self.prefix
29
- self.prefix = self.prefix.split("/")[0..-2].append("pickup").join("/")
30
- result = yield
31
- self.prefix = ori_prefix
32
- result
27
+
28
+ def set_prefix_to_list_all_locations
29
+ set_resource('pickup') do
30
+ yield
31
+ end
33
32
  end
34
33
 
35
34
  def find_every(options)
36
- set_prefix_to_list do
35
+ set_prefix_to_list_all_locations do
37
36
  prefix_options, query_options = split_options(options[:params])
38
37
  path = collection_path(prefix_options, query_options)
39
38
  instantiate_collection((format.decode(connection.get(path, headers).body) || []), query_options, prefix_options)
@@ -0,0 +1,16 @@
1
+ module ShiprocketAPI
2
+ class Tracking < Base
3
+ self.prefix += "/courier/track/awb"
4
+ self.element_name = ""
5
+
6
+ class << self
7
+
8
+ def find_by_shipment_id(id)
9
+ set_resource('shipment') do
10
+ find(id)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module ShiprocketAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.0
4
+ version: 0.2.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: 2020-10-22 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -139,6 +139,7 @@ files:
139
139
  - lib/shiprocket_api/resources/order_item.rb
140
140
  - lib/shiprocket_api/resources/pickup_location.rb
141
141
  - lib/shiprocket_api/resources/session.rb
142
+ - lib/shiprocket_api/resources/tracking.rb
142
143
  - lib/shiprocket_api/version.rb
143
144
  - shiprocket_api.gemspec
144
145
  homepage: https://github.com/PostCo/sendle_api