postmen-rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/lib/postmen.rb +23 -0
- data/lib/postmen/address.rb +40 -0
- data/lib/postmen/base.rb +1 -0
- data/lib/postmen/base/create_label.rb +17 -0
- data/lib/postmen/billing.rb +13 -0
- data/lib/postmen/carrier.rb +110 -0
- data/lib/postmen/carriers.rb +23 -0
- data/lib/postmen/carriers/fedex.rb +19 -0
- data/lib/postmen/common.rb +22 -0
- data/lib/postmen/custom.rb +2 -0
- data/lib/postmen/custom/aes.rb +15 -0
- data/lib/postmen/custom/no_eei.rb +15 -0
- data/lib/postmen/custom/passport.rb +15 -0
- data/lib/postmen/customs.rb +21 -0
- data/lib/postmen/dimension.rb +17 -0
- data/lib/postmen/invoice.rb +17 -0
- data/lib/postmen/item.rb +26 -0
- data/lib/postmen/money.rb +13 -0
- data/lib/postmen/parcel.rb +19 -0
- data/lib/postmen/payment_method_account.rb +17 -0
- data/lib/postmen/service_option_cod.rb +13 -0
- data/lib/postmen/service_option_general.rb +13 -0
- data/lib/postmen/service_option_insurance.rb +13 -0
- data/lib/postmen/shipment.rb +15 -0
- data/lib/postmen/version.rb +3 -0
- data/lib/postmen/weight.rb +13 -0
- data/postmen.gemspec +32 -0
- metadata +112 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d4cfefa98de171ee4a1aa22d9978a0bb63751dcd
|
|
4
|
+
data.tar.gz: d98e85c7ac932db594f5d28d79fbba9133306eb6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: abe19a3547491854a3ad0b4378fa83d98f906b978704c1cc515ae9bca946567df1929f90ef1c3b56888f3f1f4f618a06e17680c55c740d0a1636c0b14f031851
|
|
7
|
+
data.tar.gz: c12fc4645a56b89107a98872693ddd43918fbb25166bf39b8d4c4283a90ecc41625b2135eb06aab2095159570d514bb13e295124b23c4f0ce227089f64bc9e39
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at nitin@39shops.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Nitin-Salunke
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Postmen
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/postmen`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'postmen'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install postmen
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/postmen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
41
|
+
|
data/Rakefile
ADDED
data/lib/postmen.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'postmen/version'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
# Require postmen modules
|
|
5
|
+
require 'postmen/carrier'
|
|
6
|
+
require 'postmen/carriers'
|
|
7
|
+
require 'postmen/common'
|
|
8
|
+
require 'postmen/address'
|
|
9
|
+
require 'postmen/dimension'
|
|
10
|
+
require 'postmen/item'
|
|
11
|
+
require 'postmen/parcel'
|
|
12
|
+
require 'postmen/shipment'
|
|
13
|
+
require 'postmen/invoice'
|
|
14
|
+
require 'postmen/service_option_general'
|
|
15
|
+
require 'postmen/service_option_insurance'
|
|
16
|
+
require 'postmen/service_option_cod'
|
|
17
|
+
require 'postmen/custom'
|
|
18
|
+
require 'postmen/base'
|
|
19
|
+
require 'postmen/billing'
|
|
20
|
+
require 'postmen/payment_method_account'
|
|
21
|
+
require 'postmen/money'
|
|
22
|
+
require 'postmen/weight'
|
|
23
|
+
require 'postmen/customs'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Address
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :country,
|
|
6
|
+
:contact_name,
|
|
7
|
+
:phone,
|
|
8
|
+
:fax,
|
|
9
|
+
:email,
|
|
10
|
+
:company_name,
|
|
11
|
+
:street1,
|
|
12
|
+
:street2,
|
|
13
|
+
:street3,
|
|
14
|
+
:city,
|
|
15
|
+
:state,
|
|
16
|
+
:type,
|
|
17
|
+
:postal_code,
|
|
18
|
+
:type,
|
|
19
|
+
:tax_id
|
|
20
|
+
|
|
21
|
+
def initialize(options)
|
|
22
|
+
@country = options[:country]
|
|
23
|
+
@contact_name = options[:contact_name]
|
|
24
|
+
@phone = options[:phone]
|
|
25
|
+
@fax = options[:fax]
|
|
26
|
+
@email = options[:email]
|
|
27
|
+
@company_name = options[:company_name]
|
|
28
|
+
@street1 = options[:street1]
|
|
29
|
+
@street2 = options[:street2]
|
|
30
|
+
@street3 = options[:street3]
|
|
31
|
+
@city = options[:city]
|
|
32
|
+
@state = options[:state]
|
|
33
|
+
@type = options[:type]
|
|
34
|
+
@postal_code = options[:postal_code]
|
|
35
|
+
@type = options[:type]
|
|
36
|
+
@tax_id = options[:tax_id]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/postmen/base.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'postmen/base/create_label'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
module Base
|
|
3
|
+
class CreateLabel
|
|
4
|
+
include Postmen::Common
|
|
5
|
+
|
|
6
|
+
attr_reader :return_shipment,
|
|
7
|
+
:paper_size,
|
|
8
|
+
:service_type
|
|
9
|
+
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@return_shipment = options[:return_shipment]
|
|
12
|
+
@paper_size = options[:paper_size] || 'default'
|
|
13
|
+
@service_type = options[:service_type]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
module Postmen
|
|
5
|
+
class Carrier
|
|
6
|
+
|
|
7
|
+
SANDBOX = 'https://sandbox-api.postmen.com/v3'
|
|
8
|
+
PRODUCTION = 'https://production-api.postmen.com/v3'
|
|
9
|
+
|
|
10
|
+
attr_reader :api_key,
|
|
11
|
+
:mode,
|
|
12
|
+
:api_url,
|
|
13
|
+
:async,
|
|
14
|
+
:is_document,
|
|
15
|
+
:shipper_account_ids #Array of multiple shipper account id's
|
|
16
|
+
|
|
17
|
+
def initialize(options)
|
|
18
|
+
@api_key = options[:api_key]
|
|
19
|
+
@mode = options[:mode]
|
|
20
|
+
@api_url = get_api_url(options[:mode])
|
|
21
|
+
@async = options[:async]
|
|
22
|
+
@is_document = options[:is_document]
|
|
23
|
+
@shipper_account_ids = options[:shipper_account_ids]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def calculate_rates(shipment)
|
|
27
|
+
request_body = {
|
|
28
|
+
async: self.async,
|
|
29
|
+
is_document: self.is_document
|
|
30
|
+
}
|
|
31
|
+
shipper_accounts = []
|
|
32
|
+
self.shipper_account_ids.each do |account|
|
|
33
|
+
shipper_accounts << {id: account}
|
|
34
|
+
end
|
|
35
|
+
request_body.merge!(shipper_accounts: shipper_accounts)
|
|
36
|
+
request_body.merge!(shipment: shipment.to_hash)
|
|
37
|
+
process_request("#{api_url}/rates", 'POST', request_body)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def retrieve_rates_by_id
|
|
41
|
+
raise NotImplementedError, "Method: retrieve_rates_by_id is not supported by #{self.class.name}."
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_label(base, invoice, messages, billing, shipment, service_options = nil, customs = nil)
|
|
45
|
+
request_body = {
|
|
46
|
+
async: self.async,
|
|
47
|
+
is_document: self.is_document
|
|
48
|
+
}
|
|
49
|
+
request_body.merge!(base.to_hash)
|
|
50
|
+
request_body.merge!(invoice: invoice.to_hash)
|
|
51
|
+
request_body.merge!(references: messages) #Reference messages for shipment.
|
|
52
|
+
request_body.merge!(shipper_account: {id: self.shipper_account_ids.first})
|
|
53
|
+
request_body.merge!(billing: billing.to_hash)
|
|
54
|
+
request_body.merge!(shipment: shipment.to_hash)
|
|
55
|
+
request_body.merge!(service_options: service_options.collect{|options| options.to_hash}) unless service_options.empty?
|
|
56
|
+
request_body.merge!(customs: customs.to_hash) if customs
|
|
57
|
+
process_request("#{api_url}/labels", 'POST', request_body)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def retrieve_label_by_id
|
|
61
|
+
raise NotImplementedError, "Method: retrieve_label_by_id is not supported by #{self.class.name}."
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def list_all_label
|
|
65
|
+
raise NotImplementedError, "Method: list_all_label is not supported by #{self.class.name}."
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def cancel_label
|
|
69
|
+
raise NotImplementedError, "Method: cancel_label is not supported by #{self.class.name}."
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def list_all_cancel_labels
|
|
73
|
+
raise NotImplementedError, "Method: list_all_cancel_labels is not supported by #{self.class.name}."
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def retrieve_cancel_label_by_id
|
|
77
|
+
raise NotImplementedError, "Method: retrieve_cancel_label_by_id is not supported by #{self.class.name}."
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
def get_api_url(mode)
|
|
82
|
+
case mode
|
|
83
|
+
when 'production'
|
|
84
|
+
PRODUCTION
|
|
85
|
+
when 'sandbox'
|
|
86
|
+
SANDBOX
|
|
87
|
+
else
|
|
88
|
+
''
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def process_request(url, method, body = nil)
|
|
94
|
+
url = URI(url)
|
|
95
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
96
|
+
http.use_ssl = true
|
|
97
|
+
request = case method
|
|
98
|
+
when 'GET'
|
|
99
|
+
Net::HTTP::Get.new(url)
|
|
100
|
+
when 'POST'
|
|
101
|
+
Net::HTTP::Post.new(url)
|
|
102
|
+
end
|
|
103
|
+
request['postmen-api-key'] = api_key
|
|
104
|
+
request['content-type'] = 'application/json'
|
|
105
|
+
request.body = body.to_json if body
|
|
106
|
+
response = http.request(request)
|
|
107
|
+
JSON.parse(response.body)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
module Carriers
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
attr_reader :registered
|
|
6
|
+
@registered = []
|
|
7
|
+
|
|
8
|
+
def register(class_name, autoload_require)
|
|
9
|
+
Postmen.autoload(class_name, autoload_require)
|
|
10
|
+
self.registered << class_name
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def all
|
|
14
|
+
Postmen::Carriers.registered.map { |name| Postmen.const_get(name) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def find(name)
|
|
18
|
+
all.find { |c| c.name.downcase == name.to_s.downcase } or raise NameError, "unknown carrier #{name}"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Postmen::Carriers.register :Fedex, 'postmen/carriers/fedex'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Fedex < Carrier
|
|
3
|
+
|
|
4
|
+
BILLING = {
|
|
5
|
+
:paid_by => %W(shipper recipient third_party)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
PARCEL ={
|
|
9
|
+
:box_type => %w(custom fedex_10kg_box fedex_25kg_box fedex_box fedex_envelope fedex_extra_large_box fedex_large_box fedex_medium_box fedex_pak fedex_small_box fedex_tube)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
SERVICE_TYPE = %w(fedex_2_day fedex_2_day_am fedex_2_day_am_one_rate fedex_2_day_one_rate fedex_distance_deferred fedex_europe_first_international_priority fedex_express_saver fedex_express_saver_one_rate fedex_first_overnight fedex_first_overnight_one_rate fedex_ground fedex_ground_home_delivery fedex_international_economy fedex_international_first fedex_international_priority fedex_next_day_afternoon fedex_next_day_early_morning fedex_next_day_end_of_day fedex_next_day_mid_morning fedex_priority_overnight fedex_priority_overnight_one_rate fedex_same_day fedex_same_day_city fedex_standard_overnight fedex_standard_overnight_one_rate)
|
|
13
|
+
|
|
14
|
+
def retrieve_rates_by_id
|
|
15
|
+
raise NotImplementedError "Method: retrieve_rates_by_id is not supported by #{self.class.name}."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
module Common
|
|
3
|
+
|
|
4
|
+
def to_hash
|
|
5
|
+
hash = {}
|
|
6
|
+
instance_variables.map do |var|
|
|
7
|
+
value = instance_variable_get(var)
|
|
8
|
+
if instance_variable_get(var)
|
|
9
|
+
hash[var[1..-1].to_sym] = if value.is_a?(Array)
|
|
10
|
+
value.collect{|val|
|
|
11
|
+
(val.class.to_s.include?('Postmen') ? val.to_hash : val)
|
|
12
|
+
}
|
|
13
|
+
else
|
|
14
|
+
(value.class.to_s.include?('Postmen') ? value.to_hash : value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
hash
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Customs
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :purpose,
|
|
6
|
+
:terms_of_trade,
|
|
7
|
+
:eei,
|
|
8
|
+
:billing,
|
|
9
|
+
:importer_address,
|
|
10
|
+
:passport
|
|
11
|
+
|
|
12
|
+
def initialize(options)
|
|
13
|
+
@purpose = options[:purpose]
|
|
14
|
+
@terms_of_trade = options[:terms_of_trade]
|
|
15
|
+
@eei = options[:eei]
|
|
16
|
+
@billing = options[:billing]
|
|
17
|
+
@importer_address = options[:importer_address]
|
|
18
|
+
@passport = options[:passport]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Dimension
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :width,
|
|
6
|
+
:height,
|
|
7
|
+
:depth,
|
|
8
|
+
:unit
|
|
9
|
+
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@width = options[:width]
|
|
12
|
+
@height = options[:height]
|
|
13
|
+
@depth = options[:depth]
|
|
14
|
+
@unit = options[:unit]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Invoice
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :date,
|
|
6
|
+
:number,
|
|
7
|
+
:type,
|
|
8
|
+
:number_of_copies
|
|
9
|
+
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@date = options[:date] # In YYYY-MM-DD format
|
|
12
|
+
@number = options[:number]
|
|
13
|
+
@type = options[:type]
|
|
14
|
+
@number_of_copies = options[:number_of_copies]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/postmen/item.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Item
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :description,
|
|
6
|
+
:quantity,
|
|
7
|
+
:price,
|
|
8
|
+
:weight,
|
|
9
|
+
:item_id,
|
|
10
|
+
:origin_country,
|
|
11
|
+
:sku,
|
|
12
|
+
:hs_code
|
|
13
|
+
|
|
14
|
+
def initialize(options)
|
|
15
|
+
@description = options[:description]
|
|
16
|
+
@quantity = options[:quantity]
|
|
17
|
+
@price = options[:price]
|
|
18
|
+
@weight = options[:weight]
|
|
19
|
+
@item_id = options[:item_id]
|
|
20
|
+
@origin_country = options[:origin_country]
|
|
21
|
+
@sku = options[:sku]
|
|
22
|
+
@hs_code = options[:hs_code]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Parcel
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :box_type,
|
|
6
|
+
:dimension,
|
|
7
|
+
:items,
|
|
8
|
+
:description,
|
|
9
|
+
:weight
|
|
10
|
+
|
|
11
|
+
def initialize(options)
|
|
12
|
+
@box_type = options[:box_type]
|
|
13
|
+
@dimension = options[:dimension]
|
|
14
|
+
@items = options[:items]
|
|
15
|
+
@description = options[:description]
|
|
16
|
+
@weight = options[:weight]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class PaymentMethodAccount
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :type,
|
|
6
|
+
:account_number,
|
|
7
|
+
:postal_code,
|
|
8
|
+
:country
|
|
9
|
+
|
|
10
|
+
def initialize(options)
|
|
11
|
+
@type = options[:type]
|
|
12
|
+
@account_number = options[:account_number]
|
|
13
|
+
@postal_code = options[:postal_code]
|
|
14
|
+
@country = options[:country]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Postmen
|
|
2
|
+
class Shipment
|
|
3
|
+
include Postmen::Common
|
|
4
|
+
|
|
5
|
+
attr_reader :ship_from,
|
|
6
|
+
:ship_to,
|
|
7
|
+
:parcels
|
|
8
|
+
|
|
9
|
+
def initialize(options)
|
|
10
|
+
@ship_from = options[:ship_from]
|
|
11
|
+
@ship_to = options[:ship_to]
|
|
12
|
+
@parcels = options[:parcels]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/postmen.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'postmen/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'postmen-rb'
|
|
8
|
+
spec.version = Postmen::VERSION
|
|
9
|
+
spec.authors = ['Nitin-Salunke']
|
|
10
|
+
spec.email = ['nitin@ecomnation.in']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'Shipping API wrapper for postmen.'
|
|
13
|
+
spec.description = 'Ruby Shipping API wrapper for postmen.'
|
|
14
|
+
spec.homepage = 'https://github.com/Nitin-Salunke/postmen'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
21
|
+
else
|
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = 'exe'
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ['lib']
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
|
31
|
+
spec.add_development_dependency 'json', '~> 1.8', '>= 1.8.3'
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: postmen-rb
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nitin-Salunke
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.8'
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: 1.8.3
|
|
37
|
+
type: :development
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - "~>"
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '1.8'
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 1.8.3
|
|
47
|
+
description: Ruby Shipping API wrapper for postmen.
|
|
48
|
+
email:
|
|
49
|
+
- nitin@ecomnation.in
|
|
50
|
+
executables: []
|
|
51
|
+
extensions: []
|
|
52
|
+
extra_rdoc_files: []
|
|
53
|
+
files:
|
|
54
|
+
- ".gitignore"
|
|
55
|
+
- CODE_OF_CONDUCT.md
|
|
56
|
+
- Gemfile
|
|
57
|
+
- LICENSE.txt
|
|
58
|
+
- README.md
|
|
59
|
+
- Rakefile
|
|
60
|
+
- lib/postmen.rb
|
|
61
|
+
- lib/postmen/address.rb
|
|
62
|
+
- lib/postmen/base.rb
|
|
63
|
+
- lib/postmen/base/create_label.rb
|
|
64
|
+
- lib/postmen/billing.rb
|
|
65
|
+
- lib/postmen/carrier.rb
|
|
66
|
+
- lib/postmen/carriers.rb
|
|
67
|
+
- lib/postmen/carriers/fedex.rb
|
|
68
|
+
- lib/postmen/common.rb
|
|
69
|
+
- lib/postmen/custom.rb
|
|
70
|
+
- lib/postmen/custom/aes.rb
|
|
71
|
+
- lib/postmen/custom/no_eei.rb
|
|
72
|
+
- lib/postmen/custom/passport.rb
|
|
73
|
+
- lib/postmen/customs.rb
|
|
74
|
+
- lib/postmen/dimension.rb
|
|
75
|
+
- lib/postmen/invoice.rb
|
|
76
|
+
- lib/postmen/item.rb
|
|
77
|
+
- lib/postmen/money.rb
|
|
78
|
+
- lib/postmen/parcel.rb
|
|
79
|
+
- lib/postmen/payment_method_account.rb
|
|
80
|
+
- lib/postmen/service_option_cod.rb
|
|
81
|
+
- lib/postmen/service_option_general.rb
|
|
82
|
+
- lib/postmen/service_option_insurance.rb
|
|
83
|
+
- lib/postmen/shipment.rb
|
|
84
|
+
- lib/postmen/version.rb
|
|
85
|
+
- lib/postmen/weight.rb
|
|
86
|
+
- postmen.gemspec
|
|
87
|
+
homepage: https://github.com/Nitin-Salunke/postmen
|
|
88
|
+
licenses:
|
|
89
|
+
- MIT
|
|
90
|
+
metadata:
|
|
91
|
+
allowed_push_host: https://rubygems.org
|
|
92
|
+
post_install_message:
|
|
93
|
+
rdoc_options: []
|
|
94
|
+
require_paths:
|
|
95
|
+
- lib
|
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '0'
|
|
106
|
+
requirements: []
|
|
107
|
+
rubyforge_project:
|
|
108
|
+
rubygems_version: 2.4.7
|
|
109
|
+
signing_key:
|
|
110
|
+
specification_version: 4
|
|
111
|
+
summary: Shipping API wrapper for postmen.
|
|
112
|
+
test_files: []
|