shipcloud 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/shipcloud.rb +1 -0
- data/lib/shipcloud/base.rb +1 -0
- data/lib/shipcloud/operations/find.rb +20 -0
- data/lib/shipcloud/shipment.rb +2 -2
- data/lib/shipcloud/version.rb +1 -1
- data/spec/shipcloud/shipment_spec.rb +7 -0
- metadata +2 -1
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/github/webionate/shipcloud-ruby.png)](https://codeclimate.com/github/webionate/shipcloud-ruby) [![Build Status](https://travis-ci.org/webionate/shipcloud-ruby.png?branch=master)](https://travis-ci.org/webionate/shipcloud-ruby)
|
1
2
|
# shipcloud
|
2
3
|
|
3
4
|
A Ruby wrapper for the shipcloud API
|
data/lib/shipcloud.rb
CHANGED
data/lib/shipcloud/base.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Shipcloud
|
2
|
+
module Operations
|
3
|
+
module Find
|
4
|
+
module ClassMethods
|
5
|
+
# Finds a given object
|
6
|
+
#
|
7
|
+
# @param [String] id The id of the object that should be found
|
8
|
+
# @return [Shipcloud::Base] The found object
|
9
|
+
def find(id)
|
10
|
+
response = Shipcloud.request(:get, "#{self.name.split("::").last.downcase}s/#{id}", {})
|
11
|
+
self.new(response)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.included(base)
|
16
|
+
base.extend(ClassMethods)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/shipcloud/shipment.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Shipcloud
|
2
2
|
class Shipment < Base
|
3
3
|
|
4
|
-
attr_accessor :to, :carrier, :package
|
5
|
-
attr_reader :id, :tracking_url, :label_url, :price
|
4
|
+
attr_accessor :from, :to, :carrier, :package, :reference_number
|
5
|
+
attr_reader :id, :created_at, :carrier_tracking_no, :tracking_url, :label_url, :packages, :price
|
6
6
|
end
|
7
7
|
end
|
data/lib/shipcloud/version.rb
CHANGED
@@ -51,4 +51,11 @@ describe Shipcloud::Shipment do
|
|
51
51
|
Shipcloud::Shipment.create(valid_attributes)
|
52
52
|
end
|
53
53
|
end
|
54
|
+
|
55
|
+
describe ".find" do
|
56
|
+
it "makes a new GET request using the correct API endpoint to receive a specific subscription" do
|
57
|
+
Shipcloud.should_receive(:request).with(:get, "shipments/123", {}).and_return("id" => "123")
|
58
|
+
Shipcloud::Shipment.find("123")
|
59
|
+
end
|
60
|
+
end
|
54
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/shipcloud.rb
|
92
92
|
- lib/shipcloud/base.rb
|
93
93
|
- lib/shipcloud/operations/create.rb
|
94
|
+
- lib/shipcloud/operations/find.rb
|
94
95
|
- lib/shipcloud/request/base.rb
|
95
96
|
- lib/shipcloud/request/connection.rb
|
96
97
|
- lib/shipcloud/request/info.rb
|