myparcel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.env.example +1 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +15 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Guardfile +59 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/myparcel/api/base.rb +45 -0
- data/lib/myparcel/api/delivery_options.rb +11 -0
- data/lib/myparcel/api/shipments.rb +46 -0
- data/lib/myparcel/api/tracktraces.rb +19 -0
- data/lib/myparcel/api/webhook_subscriptions.rb +28 -0
- data/lib/myparcel/authentication.rb +32 -0
- data/lib/myparcel/client.rb +54 -0
- data/lib/myparcel/version.rb +3 -0
- data/lib/myparcel.rb +46 -0
- data/myparcel.gemspec +37 -0
- metadata +208 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NThiNjEwZmFhMWNkY2NiMDY1YjdiN2ZkM2VmMzg4MTYwNTcyYjM0OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDNjMWM3OTZkYWEyMmUyN2NkYjBlNDk5YmU4NzdkM2Q4ZDcyYjdkOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDJiY2JiNjE3NmQ0Y2U2Y2M1NDYyMjhhMTlkYjI3NzlhMjM3ZDNjZTlkMDBj
|
10
|
+
MDYyZDFmOWRlOGJmNDI0MGVkMGIzYjAxZjZiODg2NDFhZjVkOTdmZmViNWI1
|
11
|
+
NDJmMDE1YTgxMDcxMzliNWM2NmI0ZjVlNjNiNDQ2NmIzMDM5ZTI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2I5NTFhNDMyYjhiMmNkM2UwNDkyZjJmZjAwNjVjN2IxZTg4ZmM5MzUzZmNj
|
14
|
+
NmQxNTBiNDEyMTNkNjZiMmJmNDU5YjZjNTM4MDNmNmVkYTYzODc3MTAwNWY1
|
15
|
+
NDM0MWI5NDAwYzI5ZmEyMGNjOGJhMDNhMDVkM2EyYThjMzg5NDQ=
|
data/.env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
MYPARCEL_API_KEY=myparcel_api_key
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-09-12 17:50:08 +0200 using RuboCop version 0.42.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
- 'test/**/*'
|
14
|
+
- 'lib/myparcel.rb'
|
15
|
+
- 'lib/myparcel/list_shipments.rb'
|
data/.travis.yml
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 ivan@lesslines.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/Guardfile
ADDED
@@ -0,0 +1,59 @@
|
|
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.exists?(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
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
40
|
+
require 'guard/rspec/dsl'
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
end
|
55
|
+
|
56
|
+
guard :rubocop do
|
57
|
+
watch(/.+\.rb$/)
|
58
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
59
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ivan Malykh
|
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,42 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/ivdma/myparcel.svg?branch=master)](https://travis-ci.org/ivdma/myparcel)
|
2
|
+
|
3
|
+
# Myparcel
|
4
|
+
|
5
|
+
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/myparcel`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'myparcel'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install myparcel
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/myparcel. 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.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "myparcel"
|
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
@@ -0,0 +1,45 @@
|
|
1
|
+
module Myparcel
|
2
|
+
module API
|
3
|
+
# Base class for all endpoints
|
4
|
+
class Base
|
5
|
+
attr_accessor :path
|
6
|
+
attr_reader :authentication
|
7
|
+
|
8
|
+
def initialize(authentication)
|
9
|
+
@authentication = authentication
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
# rubocop:disable MethodLength
|
15
|
+
def request(method, path, options = {})
|
16
|
+
url = [authentication.host, path].join '/'
|
17
|
+
httparty_options = {
|
18
|
+
query: options.fetch(:query, {}),
|
19
|
+
body: options.fetch(:body, ''),
|
20
|
+
headers: authentication.headers.update(options[:headers] || {})
|
21
|
+
}
|
22
|
+
response = HTTParty.send method, url, httparty_options
|
23
|
+
|
24
|
+
case response.code
|
25
|
+
when 200..201
|
26
|
+
response
|
27
|
+
when 422
|
28
|
+
raise "Unprocessable entity for `#{method} #{url}` with #{httparty_options}."
|
29
|
+
else
|
30
|
+
raise 'Something went wrong'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# rubocop:enable MethodLength
|
34
|
+
|
35
|
+
def headers_for_shipment(type)
|
36
|
+
case type
|
37
|
+
when :standard then 'application/vnd.shipment+json; charset=utf-8'
|
38
|
+
when :return then 'application/vnd.return_shipment+json; charset=utf-8'
|
39
|
+
when :unrelated then 'application/vnd.unrelated_return_shipment+json; charset=utf-8'
|
40
|
+
else 'application/vnd.shipment+json; charset=utf-8'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Myparcel
|
2
|
+
module API
|
3
|
+
# Class for getting shipments
|
4
|
+
class Shipments < Myparcel::API::Base
|
5
|
+
def find(options = {})
|
6
|
+
shipment_ids = options.fetch(:shipment_ids, [])
|
7
|
+
shipment_ids = shipment_ids.join(';') if shipment_ids.is_a?(Array)
|
8
|
+
|
9
|
+
full_path = shipment_ids.empty? ? path : [path, shipment_ids].join('/')
|
10
|
+
|
11
|
+
response = request :get, full_path, options
|
12
|
+
response['data']['shipments']
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(options = {})
|
16
|
+
shipment_type = options.fetch(:shipment_type, :standard)
|
17
|
+
shipments = options.fetch(:shipments, [])
|
18
|
+
raise 'options[:shipments] must have at least one shipment.' if shipments.empty?
|
19
|
+
|
20
|
+
options[:headers] ||= {}
|
21
|
+
options[:headers]['Content-Type'] = headers_for_shipment(shipment_type)
|
22
|
+
|
23
|
+
options[:body] ||= {}
|
24
|
+
options[:body] = JSON.generate(data: { shipments: shipments })
|
25
|
+
|
26
|
+
response = request :post, path, options
|
27
|
+
response['data']['ids']
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(options = {})
|
31
|
+
shipment_ids = options.fetch :shipment_ids, []
|
32
|
+
raise 'options[:shipment_ids] cannot be empty or nil' if shipment_ids.empty?
|
33
|
+
|
34
|
+
shipment_ids = shipment_ids.join(';')
|
35
|
+
full_path = [path, shipment_ids].join('/')
|
36
|
+
|
37
|
+
response = request :delete, full_path, options
|
38
|
+
response['data']
|
39
|
+
end
|
40
|
+
|
41
|
+
def path
|
42
|
+
'shipments'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Myparcel
|
2
|
+
module API
|
3
|
+
# Class for managing tracktraces
|
4
|
+
class Tracktraces < Myparcel::API::Base
|
5
|
+
def find(options = {})
|
6
|
+
shipment_ids = options.fetch(:shipment_ids, [])
|
7
|
+
raise 'options[:shipment_ids] cannot be empty' if shipment_ids.empty?
|
8
|
+
shipment_ids = shipment_ids.join(';')
|
9
|
+
full_path = [path, shipment_ids].join('/')
|
10
|
+
response = request :get, full_path, options
|
11
|
+
response['data']['tracktraces']
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
'tracktraces'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Myparcel
|
2
|
+
module API
|
3
|
+
# Class for getting delivery options
|
4
|
+
class WebhookSubscriptions < Myparcel::API::Base
|
5
|
+
def find(options = {})
|
6
|
+
subscription_ids = options.fetch(:subscription_ids, [])
|
7
|
+
raise ArgumentError, 'options[:subscription_ids] cannot be empty' if subscription_ids.empty?
|
8
|
+
subscription_ids = subscription_ids.join(';')
|
9
|
+
full_path = [path, subscription_ids].join('/')
|
10
|
+
response = request :get, full_path
|
11
|
+
response['data']['webhook_subscriptions']
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(options = {})
|
15
|
+
subscriptions = options.fetch(:subscriptions, [])
|
16
|
+
options[:body] = JSON.generate(data: { webhook_subscriptions: subscriptions })
|
17
|
+
options[:headers] ||= {}
|
18
|
+
options[:headers]['Content-Type'] = 'application/json; charset=utf-8'
|
19
|
+
response = request :post, path, options
|
20
|
+
response['data']['ids']
|
21
|
+
end
|
22
|
+
|
23
|
+
def path
|
24
|
+
'webhook_subscriptions'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Myparcel
|
2
|
+
# Creates authentication headers
|
3
|
+
class Authentication
|
4
|
+
attr_accessor :api_key
|
5
|
+
|
6
|
+
def initialize(api_key = ENV['MYPARCEL_API_KEY'])
|
7
|
+
@api_key = api_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def headers
|
11
|
+
{ 'Authorization' => "basic #{auth_token}" }
|
12
|
+
end
|
13
|
+
|
14
|
+
def auth_token
|
15
|
+
Base64.urlsafe_encode64(api_key)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Could have used api_key.present? but
|
19
|
+
# it wasn't avavailable in 1.9.3 yet for Object nor for String
|
20
|
+
def valid?
|
21
|
+
!api_key.nil? && api_key.size > 0
|
22
|
+
end
|
23
|
+
|
24
|
+
def invalid?
|
25
|
+
!valid?
|
26
|
+
end
|
27
|
+
|
28
|
+
def host
|
29
|
+
'https://api.myparcel.nl'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Myparcel
|
2
|
+
# Represents a client for the API
|
3
|
+
class Client
|
4
|
+
attr_accessor :authentication
|
5
|
+
|
6
|
+
def initialize(api_key = nil)
|
7
|
+
@authentication = Myparcel::Authentication.new(api_key)
|
8
|
+
raise 'No credentials provided' if @authentication.invalid?
|
9
|
+
end
|
10
|
+
|
11
|
+
# Get delivery options for an address
|
12
|
+
#
|
13
|
+
# == Usage:
|
14
|
+
#
|
15
|
+
# ```ruby
|
16
|
+
# client.delivery_options.find({...})
|
17
|
+
# ```
|
18
|
+
def delivery_options
|
19
|
+
@delivery_options ||= Myparcel::API::DeliveryOptions.new(authentication)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Shipments management endpoint
|
23
|
+
#
|
24
|
+
# == Usage:
|
25
|
+
#
|
26
|
+
# Create shipments:
|
27
|
+
#
|
28
|
+
# ```ruby
|
29
|
+
# client = Myparcel.client('api_key')
|
30
|
+
# client.shipments.create(shipments: [{...}])
|
31
|
+
# ```
|
32
|
+
#
|
33
|
+
# Find shipments:
|
34
|
+
#
|
35
|
+
# ```ruby
|
36
|
+
# # returns all available shipments:
|
37
|
+
# client.shipments.find
|
38
|
+
#
|
39
|
+
# # returns shipments by id
|
40
|
+
# client.shipments.find(shipment_ids: [1, 2])
|
41
|
+
# ```
|
42
|
+
def shipments
|
43
|
+
@shipments ||= Myparcel::API::Shipments.new(authentication)
|
44
|
+
end
|
45
|
+
|
46
|
+
def tracktraces
|
47
|
+
@tracktraces ||= Myparcel::API::Tracktraces.new(authentication)
|
48
|
+
end
|
49
|
+
|
50
|
+
def webhooks
|
51
|
+
@webhooks ||= Myparcel::API::WebhookSubscriptions.new(authentication)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/myparcel.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'virtus'
|
3
|
+
require 'base64'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
require 'myparcel/version'
|
7
|
+
|
8
|
+
require 'myparcel/authentication'
|
9
|
+
require 'myparcel/client'
|
10
|
+
|
11
|
+
require 'myparcel/api/base'
|
12
|
+
require 'myparcel/api/delivery_options'
|
13
|
+
require 'myparcel/api/shipments'
|
14
|
+
require 'myparcel/api/tracktraces'
|
15
|
+
require 'myparcel/api/webhook_subscriptions'
|
16
|
+
|
17
|
+
# Ruby API Wrapper for https://api.myparcel.nl
|
18
|
+
module Myparcel
|
19
|
+
class << self
|
20
|
+
# == Usage:
|
21
|
+
#
|
22
|
+
# === Initialize client
|
23
|
+
#
|
24
|
+
# With `ENV['MYPARCEL_API_KEY']`:
|
25
|
+
#
|
26
|
+
# ```ruby
|
27
|
+
# client = Myparcel.client
|
28
|
+
# ```
|
29
|
+
#
|
30
|
+
# with parameter:
|
31
|
+
#
|
32
|
+
# ```ruby
|
33
|
+
# client = Myparcel.client('your-api-key')
|
34
|
+
# ```
|
35
|
+
#
|
36
|
+
# === Get Shipments
|
37
|
+
#
|
38
|
+
# ```ruby
|
39
|
+
# client = Myparcel.client('your-api-key')
|
40
|
+
# client.shipments.find
|
41
|
+
# ```
|
42
|
+
def client(api_key = nil)
|
43
|
+
@client ||= Myparcel::Client.new(api_key)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/myparcel.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'myparcel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'myparcel'
|
8
|
+
spec.version = Myparcel::VERSION
|
9
|
+
spec.authors = ['Ivan Malykh']
|
10
|
+
spec.email = ['ivan@lesslines.com']
|
11
|
+
|
12
|
+
spec.summary = 'MyParcel API Ruby wrapper.'
|
13
|
+
spec.description = 'Ruby wrapper for MyParcel API.'
|
14
|
+
spec.homepage = 'https://github.com/ivdma/myparcel'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'httparty', '~> 0.14.0'
|
23
|
+
spec.add_dependency 'virtus'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
# spec.add_development_dependency 'guard-bundler', '~> 2.1'
|
29
|
+
# spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
30
|
+
# spec.add_development_dependency 'guard-rubocop'
|
31
|
+
# spec.add_development_dependency 'rubocop', '~> 0.42'
|
32
|
+
spec.add_development_dependency 'webmock', '~> 1.24'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
35
|
+
spec.add_development_dependency 'timecop', '~> 0.8'
|
36
|
+
spec.add_development_dependency 'dotenv', '~> 2.1'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myparcel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Malykh
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.14.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.14.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: virtus
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.24'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.24'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.8'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.8'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: dotenv
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.1'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.1'
|
153
|
+
description: Ruby wrapper for MyParcel API.
|
154
|
+
email:
|
155
|
+
- ivan@lesslines.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- .env.example
|
161
|
+
- .gitignore
|
162
|
+
- .rspec
|
163
|
+
- .rubocop.yml
|
164
|
+
- .rubocop_todo.yml
|
165
|
+
- .travis.yml
|
166
|
+
- CODE_OF_CONDUCT.md
|
167
|
+
- Gemfile
|
168
|
+
- Guardfile
|
169
|
+
- LICENSE.txt
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- bin/console
|
173
|
+
- bin/setup
|
174
|
+
- lib/myparcel.rb
|
175
|
+
- lib/myparcel/api/base.rb
|
176
|
+
- lib/myparcel/api/delivery_options.rb
|
177
|
+
- lib/myparcel/api/shipments.rb
|
178
|
+
- lib/myparcel/api/tracktraces.rb
|
179
|
+
- lib/myparcel/api/webhook_subscriptions.rb
|
180
|
+
- lib/myparcel/authentication.rb
|
181
|
+
- lib/myparcel/client.rb
|
182
|
+
- lib/myparcel/version.rb
|
183
|
+
- myparcel.gemspec
|
184
|
+
homepage: https://github.com/ivdma/myparcel
|
185
|
+
licenses:
|
186
|
+
- MIT
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ! '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ! '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.6.7
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: MyParcel API Ruby wrapper.
|
208
|
+
test_files: []
|