bluedart 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/README.md +61 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bluedart.gemspec +28 -0
- data/lib/bluedart.rb +7 -0
- data/lib/bluedart/base.rb +270 -0
- data/lib/bluedart/pincode_service.rb +23 -0
- data/lib/bluedart/shipment.rb +97 -0
- data/lib/bluedart/version.rb +3 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDkyMDJhNDZhNGY2Y2RkZWE0M2Q4OGQ2OTcyMGJkNGU3NmQ1N2UzMA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTg0OGRkYmM3N2RhN2Y0ODc2NzcyM2Q3MjRmYWRmZjlmZDY4YWE5Zg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWQwNWFiZjk4ZTVmOGI4MWE4OGVmMjRiYWIwODQ4ZTE3MzJkNzAyYzI5OGM5
|
10
|
+
M2JkZWRiNmMwMWI5NTI2NzdjOWI2NTQwZThmYzc2OTNkZjU2MGJjYWQ4ZWJk
|
11
|
+
MDBjY2E0NmZkMWJmNGRiNTQwYTc3OWY1OTk1MTA0ZDE4NzI4Mzc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTkzYzkxMjM0MzJlZjUzMjg3ZTg1ZDMyMTI3ZDU3YTUwODllNjk4ZDkyMmUy
|
14
|
+
YTQ3MWUxOWFhN2E1MTM3ZTA0NDBjMjAyZjMyZDNhZjRjMTI1YTY0NmU2NTVh
|
15
|
+
MDNkZGJkZjhhNGY0YWI0OGRiZGIxYzEwZTAzZThiYjhiMTNkZjQ=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Bluedart Gem
|
2
|
+
|
3
|
+
The Gem provides an interface to Bluedart APIs. Currently under development. FYI This gem is neither built nor promoted by Bluedart. To experiment with the code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bluedart'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bluedart
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Pincode API
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
pincode_details = {pincode: 411028, mode: 'development', creds: {license_key: '', login_id: ''}}
|
27
|
+
|
28
|
+
p = Bluedart::PincodeService.new(pincode_details)
|
29
|
+
p.response
|
30
|
+
```
|
31
|
+
|
32
|
+
### Shipment API
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
shipment_details = {mode: 'prod'}
|
36
|
+
|
37
|
+
shipment_details[:creds] = {license_key: '', login_id: ''}}
|
38
|
+
|
39
|
+
shipment_details[:shipper_details] = {customer_code:"", :customer_name:"J Bieber", :address:"ABC ABC", customer_pincode:"499999",customer_telephone:nil, customer_mobile:"", customer_email_id:"someone@me.com", sender:'', vendor_code:"", isToPayCustomer:false, origin_area:'AAA'}
|
40
|
+
|
41
|
+
shipment_details[:consignee_details] = {consignee_name:"Ninja", address:"hogsmeade station", consignee_pincode:"999999", consignee_telephone:"000000000", :consignee_mobile:"0000000000", consignee_attention:""}
|
42
|
+
|
43
|
+
shipment_details[:services] = {piece_count:1, actual_weight:0.1, pack_type:"", invoice_no:"", special_instruction:"", declared_value:9999, credit_reference_no:"9999", dimensions:"", pickup_date:'2015-12-12', pickup_time:"1313", commodities:['Crack'], product_type:"Dutiables", collectable_amount:5050, product_code:"A", sub_product_code:"C", p_d_f_output_not_required:false}
|
44
|
+
|
45
|
+
b = Bluedart::Shipment.new(shipment_details)
|
46
|
+
b.response
|
47
|
+
```
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it ( https://github.com/chirag7jain/bluedart/fork )
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bluedart"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bluedart.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bluedart/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bluedart"
|
8
|
+
spec.version = Bluedart::VERSION
|
9
|
+
spec.authors = ["CJ"]
|
10
|
+
spec.email = ["chirag7jain@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Bluedart Web Services}
|
13
|
+
spec.description = %q{Provides an interface to Bluedart Web Services}
|
14
|
+
spec.homepage = "https://github.com/chirag7jain/bluedart"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'nokogiri'
|
22
|
+
spec.add_dependency 'httparty'
|
23
|
+
spec.add_dependency 'nori'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "debugger"
|
28
|
+
end
|
data/lib/bluedart.rb
ADDED
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'httparty'
|
3
|
+
require 'nori'
|
4
|
+
|
5
|
+
module Bluedart
|
6
|
+
class Base
|
7
|
+
private
|
8
|
+
|
9
|
+
# input params
|
10
|
+
# details - Hash
|
11
|
+
# creds - Hash
|
12
|
+
#
|
13
|
+
# Creates profile hash
|
14
|
+
#
|
15
|
+
# Return Hash
|
16
|
+
def profile_hash(details, creds)
|
17
|
+
params = {}
|
18
|
+
params[:api_type] = details[:api_type]
|
19
|
+
params[:license_key] = creds[:license_key]
|
20
|
+
params[:login_id] = creds[:login_id]
|
21
|
+
params[:version] = details[:version]
|
22
|
+
params
|
23
|
+
end
|
24
|
+
|
25
|
+
# input params - none
|
26
|
+
#
|
27
|
+
# Creates hash containing required namespaces
|
28
|
+
#
|
29
|
+
# Returns Hash
|
30
|
+
def namespaces
|
31
|
+
ns = {}
|
32
|
+
ns[:envelope] = {key:'env', value: 'http://www.w3.org/2003/05/soap-envelope'}
|
33
|
+
ns[:content] = {key:'ns1', value: 'http://tempuri.org/'}
|
34
|
+
ns[:profile] = {key:'ns2', value: 'http://schemas.datacontract.org/2004/07/SAPI.Entities.Admin'}
|
35
|
+
ns[:wsa] = {key:'ns3', value: 'http://www.w3.org/2005/08/addressing'}
|
36
|
+
ns[:shipment] = {key:'ns4', value: 'http://schemas.datacontract.org/2004/07/SAPI.Entities.WayBillGeneration'}
|
37
|
+
ns
|
38
|
+
end
|
39
|
+
|
40
|
+
# input params - none
|
41
|
+
#
|
42
|
+
# Creates hash with xml styled namespace key and value
|
43
|
+
#
|
44
|
+
# Returns Hash
|
45
|
+
def namespace_hash
|
46
|
+
opt = {}
|
47
|
+
namespaces.each do |type, attrs|
|
48
|
+
key = "xmlns:#{attrs[:key]}"
|
49
|
+
opt[key] = attrs[:value]
|
50
|
+
end
|
51
|
+
opt
|
52
|
+
end
|
53
|
+
|
54
|
+
# input params
|
55
|
+
# name - symbol
|
56
|
+
#
|
57
|
+
# Provides key for a given namespace block
|
58
|
+
#
|
59
|
+
# Returns String
|
60
|
+
def namespace_key(name)
|
61
|
+
namespaces[name][:key]
|
62
|
+
end
|
63
|
+
|
64
|
+
# input params
|
65
|
+
# xml - Nokogiri::XML::Builder
|
66
|
+
# values - Hash
|
67
|
+
#
|
68
|
+
# Appends Profile XML Block
|
69
|
+
#
|
70
|
+
# Returns Nokogiri::XML::Builder
|
71
|
+
def profile_xml(xml, values)
|
72
|
+
ns_key = "#{namespace_key(:profile)}"
|
73
|
+
xml[ns_key].Api_type values[:api_type]
|
74
|
+
xml[ns_key].LicenceKey values[:license_key]
|
75
|
+
xml[ns_key].LoginID values[:login_id]
|
76
|
+
xml[ns_key].Version values[:version]
|
77
|
+
xml
|
78
|
+
end
|
79
|
+
|
80
|
+
# input params
|
81
|
+
# xml - Nokogiri::XML::Builder
|
82
|
+
# wsa - string
|
83
|
+
#
|
84
|
+
# Appends Header XML Block
|
85
|
+
#
|
86
|
+
# Returns Nokogiri::XML::Builder
|
87
|
+
def header_xml(xml, wsa)
|
88
|
+
xml.Header {
|
89
|
+
xml["#{namespace_key(:wsa)}"].Action(wsa, "#{namespace_key(:envelope)}:mustUnderstand" => true)
|
90
|
+
}
|
91
|
+
xml
|
92
|
+
end
|
93
|
+
|
94
|
+
# input params
|
95
|
+
# xml - Nokogiri::XML::Builder
|
96
|
+
# params - Hash
|
97
|
+
#
|
98
|
+
# Transform Hash to XML
|
99
|
+
#
|
100
|
+
# Returns Nokogiri::XML::Builder
|
101
|
+
def hash_xml(xml, params)
|
102
|
+
params.each do |key, value|
|
103
|
+
xml = xml_key_value(key, value, xml)
|
104
|
+
end
|
105
|
+
xml
|
106
|
+
end
|
107
|
+
|
108
|
+
# TODO: ITS A HACK NEEDS TO BE REMOVED
|
109
|
+
# input params
|
110
|
+
# key - string
|
111
|
+
#
|
112
|
+
# Removes last letter from string
|
113
|
+
#
|
114
|
+
# Returns String
|
115
|
+
def singular(key)
|
116
|
+
key = key[0..-2]
|
117
|
+
end
|
118
|
+
|
119
|
+
def xml_key_value(key, value, xml)
|
120
|
+
if value.is_a?(Hash)
|
121
|
+
xml.send(key) do |xml|
|
122
|
+
value.each {|inner_key, inner_values| xml = xml_key_value(inner_key, inner_values, xml)}
|
123
|
+
end
|
124
|
+
elsif value.is_a?(Array)
|
125
|
+
new_key = singular(key)
|
126
|
+
value.each do |single_value|
|
127
|
+
xml.send(key) do |xml|
|
128
|
+
xml = hash_xml(xml, single_value)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
else
|
132
|
+
xml.send(key, value)
|
133
|
+
end
|
134
|
+
xml
|
135
|
+
end
|
136
|
+
|
137
|
+
# input params
|
138
|
+
# xml - Nokogiri::XML::Builder
|
139
|
+
# message - String
|
140
|
+
# params - Hash
|
141
|
+
# extra - Hash
|
142
|
+
#
|
143
|
+
# Appends Body XML Block
|
144
|
+
#
|
145
|
+
# Returns Nokogiri::XML::Builder
|
146
|
+
def body_xml(xml, message, params, extra)
|
147
|
+
content_ns_key = "#{namespace_key(:content)}"
|
148
|
+
xml.Body {
|
149
|
+
xml[content_ns_key].send(message) do |xml|
|
150
|
+
hash_xml(xml, params)
|
151
|
+
extra.each do |key, value|
|
152
|
+
xml[content_ns_key].send(key) { profile_xml(xml, value)} if key.downcase == 'profile'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
}
|
156
|
+
xml
|
157
|
+
end
|
158
|
+
|
159
|
+
# input params
|
160
|
+
# opts - Hash
|
161
|
+
#
|
162
|
+
# Create XML Request
|
163
|
+
#
|
164
|
+
# Returns Nokogiri::XML::Builder
|
165
|
+
def request_xml(opts)
|
166
|
+
envelope_ns_key = "#{namespace_key(:envelope)}"
|
167
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
168
|
+
xml[envelope_ns_key].Envelope(namespace_hash) {
|
169
|
+
xml = header_xml(xml, opts[:wsa])
|
170
|
+
xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])
|
171
|
+
}
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# input params
|
176
|
+
# opts - Hash
|
177
|
+
#
|
178
|
+
# Fire XML request and return parsed response
|
179
|
+
#
|
180
|
+
# Returns Hash
|
181
|
+
def make_request(opts)
|
182
|
+
body = request_xml(opts)
|
183
|
+
response = request(opts[:url], body.to_xml)
|
184
|
+
response_return(response, opts[:message])
|
185
|
+
end
|
186
|
+
|
187
|
+
# input params
|
188
|
+
# response - Hash
|
189
|
+
# message - String
|
190
|
+
#
|
191
|
+
# Provides Parsed Response
|
192
|
+
#
|
193
|
+
# Returns Hash
|
194
|
+
def response_return(response, message)
|
195
|
+
response_hash = {error: false, error_text: ''}
|
196
|
+
if response[:error]
|
197
|
+
response_hash[:error] = true
|
198
|
+
response_hash[:error_text] = response[:error_message]
|
199
|
+
else
|
200
|
+
content = required_content(message, response)
|
201
|
+
if content[:is_error]
|
202
|
+
response_hash[:error] = true
|
203
|
+
response_hash[:error_text] = content[:error_message] || content[:status]
|
204
|
+
else
|
205
|
+
response_hash[:content] = content
|
206
|
+
end
|
207
|
+
end
|
208
|
+
response_hash
|
209
|
+
end
|
210
|
+
|
211
|
+
# input params
|
212
|
+
# prefix - String
|
213
|
+
# content - Hash
|
214
|
+
#
|
215
|
+
# Removes Junk content from response
|
216
|
+
#
|
217
|
+
# Returns Hash
|
218
|
+
def required_content(prefix, content)
|
219
|
+
prefix_s = prefix.snakecase
|
220
|
+
keys = (prefix_s + '_response').to_sym, (prefix_s + '_result').to_sym
|
221
|
+
content[keys[0]][keys[1]]
|
222
|
+
end
|
223
|
+
|
224
|
+
# input params
|
225
|
+
# url - String
|
226
|
+
# body - String
|
227
|
+
#
|
228
|
+
# Fires request and returns response
|
229
|
+
#
|
230
|
+
# Returns Hash
|
231
|
+
def request(url, body)
|
232
|
+
res = HTTParty.post(url, body: body, headers: {'Content-Type' => 'application/soap+xml; charset="utf-8"'}, :verify => false)
|
233
|
+
content = xml_hash(res.body)[:envelope][:body]
|
234
|
+
end
|
235
|
+
|
236
|
+
# input params
|
237
|
+
# xml - String
|
238
|
+
#
|
239
|
+
# Converts XML to Hash
|
240
|
+
#
|
241
|
+
# Returns Hash
|
242
|
+
def xml_hash(xml)
|
243
|
+
nori = Nori.new(strip_namespaces: true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym })
|
244
|
+
nori.parse(xml)
|
245
|
+
end
|
246
|
+
|
247
|
+
# input params
|
248
|
+
# address - String
|
249
|
+
# line_length - Integer
|
250
|
+
#
|
251
|
+
# Splits address into array by count of characters
|
252
|
+
#
|
253
|
+
# Returns Array
|
254
|
+
def multi_line_address(address, line_length)
|
255
|
+
multi_line_address_block = []
|
256
|
+
i = 0
|
257
|
+
address.split(/[ ,]/).each do |s|
|
258
|
+
if multi_line_address_block[i].blank?
|
259
|
+
multi_line_address_block[i] = s
|
260
|
+
elsif (multi_line_address_block[i].length + s.length < line_length)
|
261
|
+
multi_line_address_block[i] += ' ' + s
|
262
|
+
else
|
263
|
+
i += 1
|
264
|
+
multi_line_address_block[i] = s
|
265
|
+
end
|
266
|
+
end
|
267
|
+
multi_line_address_block
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bluedart
|
2
|
+
class PincodeService < Base
|
3
|
+
def initialize(details)
|
4
|
+
@pincode = details[:pincode]
|
5
|
+
@profile = profile_hash({api_type: 'S', version: '1.3'}, details[:creds])
|
6
|
+
@mode = details[:mode]
|
7
|
+
end
|
8
|
+
|
9
|
+
def request_url
|
10
|
+
if @mode == 'prod'
|
11
|
+
'https://netconnect.bluedart.com/ShippingAPI/Finder/ServiceFinderQuery.svc'
|
12
|
+
else
|
13
|
+
'https://netconnect.bluedart.com/Demo/ShippingAPI/Finder/ServiceFinderQuery.svc'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def response
|
18
|
+
wsa = 'http://tempuri.org/IServiceFinderQuery/GetServicesforPincode'
|
19
|
+
opts = {message: 'GetServicesforPincode', wsa: wsa, params: {pinCode: @pincode}, extra: {'profile' => @profile}, url: request_url}
|
20
|
+
make_request(opts)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Bluedart
|
2
|
+
class Shipment < Base
|
3
|
+
def initialize(details)
|
4
|
+
@shipper = shipper_hash(details[:shipper_details])
|
5
|
+
@consignee = consignee_hash(details[:consignee_details])
|
6
|
+
@services = services_hash(details[:services])
|
7
|
+
@profile = profile_hash({api_type: 'S', version: '1.3'}, details[:creds])
|
8
|
+
@mode = details[:mode]
|
9
|
+
end
|
10
|
+
|
11
|
+
def request_url
|
12
|
+
if @mode == 'prod'
|
13
|
+
'https://netconnect.bluedart.com/ShippingAPI/WayBill/WayBillGeneration.svc'
|
14
|
+
else
|
15
|
+
'https://netconnect.bluedart.com/Demo/ShippingAPI/WayBill/WayBillGeneration.svc'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def response
|
20
|
+
wsa = 'http://tempuri.org/IWayBillGeneration/GenerateWayBill'
|
21
|
+
# TODO: ITS A HACK NEEDS TO BE REMOVED
|
22
|
+
# TODO: NEED TO REWRITE TO USE NAMESPACES DEFINED IN NAMESPACES FUNCTION
|
23
|
+
params = {'Request' => {'ns4:Consignee' => @consignee, 'ns4:Services' => @services, 'ns4:Shipper' => @shipper}}
|
24
|
+
opts = {message: 'GenerateWayBill', wsa: wsa, params: params, extra: {'Profile' => @profile}, url: request_url}
|
25
|
+
make_request(opts)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def shipper_hash(details)
|
30
|
+
params = {}
|
31
|
+
address_array = multi_line_address(details[:address], 30)
|
32
|
+
params['CustomerAddress1'] = address_array[0]
|
33
|
+
params['CustomerAddress2'] = address_array[1]
|
34
|
+
params['CustomerAddress3'] = address_array[2]
|
35
|
+
params['CustomerCode'] = details[:customer_code]
|
36
|
+
params['CustomerEmailID'] = details[:customer_email_id]
|
37
|
+
params['CustomerMobile'] = details[:customer_mobile]
|
38
|
+
params['CustomerName'] = details[:customer_name]
|
39
|
+
params['CustomerPincode'] = details[:customer_pincode]
|
40
|
+
params['CustomerTelephone'] = details[:customer_telephone]
|
41
|
+
params['isToPayCustomer'] = details[:isToPayCustomer]
|
42
|
+
params['OriginArea'] = details[:origin_area]
|
43
|
+
params['Sender'] = details[:sender]
|
44
|
+
params['VendorCode'] = details[:vendor_code]
|
45
|
+
params
|
46
|
+
end
|
47
|
+
|
48
|
+
def consignee_hash(details)
|
49
|
+
params = {}
|
50
|
+
address_array = multi_line_address(details[:address], 30)
|
51
|
+
params['ConsigneeAddress1'] = address_array[0]
|
52
|
+
params['ConsigneeAddress2'] = address_array[1]
|
53
|
+
params['ConsigneeAddress3'] = address_array[2]
|
54
|
+
params['ConsigneeAttention'] = details[:consignee_attention]
|
55
|
+
params['ConsigneeMobile'] = details[:consignee_mobile]
|
56
|
+
params['ConsigneeName'] = details[:consignee_name]
|
57
|
+
params['ConsigneePincode'] = details[:consignee_pincode]
|
58
|
+
params['ConsigneeTelephone'] = details[:consignee_telephone]
|
59
|
+
params
|
60
|
+
end
|
61
|
+
|
62
|
+
def services_hash(details)
|
63
|
+
params = {}
|
64
|
+
params['ActualWeight'] = details[:actual_weight]
|
65
|
+
params['CollectableAmount'] = details[:collactable_amount]
|
66
|
+
params['Commodity'] = commodites_hash(details[:commodities])
|
67
|
+
params['CreditReferenceNo'] = details[:credit_reference_no]
|
68
|
+
params['DeclaredValue'] = details[:declared_value]
|
69
|
+
params['Dimensions'] = details[:diemensions]
|
70
|
+
params['InvoiceNo'] = details[:invoice_no]
|
71
|
+
params['PackType'] = details[:pack_type]
|
72
|
+
params['PickupDate'] = details[:pickup_date]
|
73
|
+
params['PickupTime'] = details[:pickup_time]
|
74
|
+
params['PieceCount'] = details[:piece_count]
|
75
|
+
params['ProductCode'] = details[:product_code]
|
76
|
+
params['ProductType'] = details[:product_type]
|
77
|
+
params['SubProductCode'] = details[:sub_product_code]
|
78
|
+
params['SpecialInstruction'] = details[:special_instruction]
|
79
|
+
params['PDFOutputNotRequired'] = details[:p_d_f_output_not_required]
|
80
|
+
params
|
81
|
+
end
|
82
|
+
|
83
|
+
def dimensions_hash(details)
|
84
|
+
params = []
|
85
|
+
details.each do |d|
|
86
|
+
params << {'Dimension' => {'Breadth' => d[:breadth], 'Height' => d[:height], 'Length' => d[:length], 'Count' => d[:count]} }
|
87
|
+
end
|
88
|
+
params
|
89
|
+
end
|
90
|
+
|
91
|
+
def commodites_hash(details)
|
92
|
+
params = {}
|
93
|
+
details.each_with_index {|d, i| params["CommodityDetail#{i+1}"] = d}
|
94
|
+
params
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bluedart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CJ
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nori
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: debugger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Provides an interface to Bluedart Web Services
|
98
|
+
email:
|
99
|
+
- chirag7jain@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- .travis.yml
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- bluedart.gemspec
|
114
|
+
- lib/bluedart.rb
|
115
|
+
- lib/bluedart/base.rb
|
116
|
+
- lib/bluedart/pincode_service.rb
|
117
|
+
- lib/bluedart/shipment.rb
|
118
|
+
- lib/bluedart/version.rb
|
119
|
+
homepage: https://github.com/chirag7jain/bluedart
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.4.6
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Bluedart Web Services
|
142
|
+
test_files: []
|