shipcloud 0.1.0 → 0.2.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.
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
@@ -20,6 +20,7 @@ module Shipcloud
20
20
 
21
21
  module Operations
22
22
  autoload :Create, "shipcloud/operations/create"
23
+ autoload :Find, "shipcloud/operations/find"
23
24
  end
24
25
 
25
26
  module Request
@@ -1,6 +1,7 @@
1
1
  module Shipcloud
2
2
  class Base
3
3
  include Shipcloud::Operations::Create
4
+ include Shipcloud::Operations::Find
4
5
 
5
6
  # Initializes an object using the given attributes
6
7
  #
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Shipcloud
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.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