snap-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8893c6ba1b64a97074146fae0aba8fe8f3bf1be9e52b19ee9bcd99aec198ff3b
4
- data.tar.gz: a50a60eab5350b42717efab3e0fa3dfd749494d9b1b93302693550378271a40a
3
+ metadata.gz: 36cecbcd40e05247522d1c72c79ae4f3efebbd53b59d43ff4075bb8dfe618ae9
4
+ data.tar.gz: f7b38ee2036e287667c2511bfceb112bc153f8917cff206601e19d37f849dfc2
5
5
  SHA512:
6
- metadata.gz: 7fd7dde555c9d92cf649ea79e5b4278142a51295c6a502d1828d3a7cd2ce934cc122f29eac7bfd08c00031dd47036b144fb0142201e2977aa68b3dd91adc064c
7
- data.tar.gz: f733aeb8f05509b02387bb06a14ad6b2394186c7e5dc2134a2b31920f9593ff77e9afca419aa9dde48d0f79a5b57c21d0ffb1cdc62d52ccc2f42425da3416549
6
+ metadata.gz: 28c1df861559b42870d2550a35580fa51639a63d476cef6a527a44f882613805cbc03f7efde68a1e898b04ebf3649c950aaa01e8565b9fc9ff707469776318bc
7
+ data.tar.gz: 53a198dc56fe9131bdddf27c12babfcb0fd2171727ad978800559944354b78e5775930a2f2be031ea7d92283730ce3004c470196b2fe58b046581c0ff63c574d
data/History.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ 0.1.2 / 2018-09-16
3
+ ==================
4
+
5
+ * Add ShipmentStatus
6
+ * Wrap HTTParty response
7
+ * Add ActiveModel validations
8
+ * Add ShipmentLine nested model
9
+
2
10
  0.1.1 / 2018-09-16
3
11
  ==================
4
12
 
@@ -0,0 +1,18 @@
1
+ module Snap
2
+ module Api
3
+ # Interact with Snapfulfil's shipment status endpoint.
4
+ class ShipmentStatus
5
+ include ::HTTParty
6
+ extend Client
7
+
8
+ def self.update(options)
9
+ shipment_status = Snap::ShipmentStatus.new(options)
10
+ client.put("/shipmentstatus/#{shipment_status.ShipmentId}", body: shipment_status)
11
+ end
12
+
13
+ def self.model
14
+ Snap::ShipmentStatus
15
+ end
16
+ end
17
+ end
18
+ end
@@ -17,6 +17,10 @@ module Snap
17
17
  shipment = Snap::Shipment.new(options)
18
18
  client.post('/shipments', body: shipment)
19
19
  end
20
+
21
+ def self.model
22
+ Snap::Shipment
23
+ end
20
24
  end
21
25
  end
22
26
  end
data/lib/snap/client.rb CHANGED
@@ -8,5 +8,33 @@ module Snap
8
8
  basic_auth(Snap.config.username, Snap.config.password)
9
9
  self
10
10
  end
11
+
12
+ def get(*args, &block)
13
+ wrap_response do
14
+ super(*args, &block)
15
+ end
16
+ end
17
+
18
+ def post(*args, &block)
19
+ wrap_response do
20
+ super(*args, &block)
21
+ end
22
+ end
23
+
24
+ def delete(*args, &block)
25
+ wrap_response do
26
+ super(*args, &block)
27
+ end
28
+ end
29
+
30
+ def put(*args, &block)
31
+ wrap_response do
32
+ super(*args, &block)
33
+ end
34
+ end
35
+
36
+ def wrap_response
37
+ Snap::Response.new(yield, model)
38
+ end
11
39
  end
12
40
  end
@@ -3,6 +3,13 @@ module Snap
3
3
  # A representation of a Snap Shipment object.
4
4
  class Shipment < Hashie::Dash
5
5
  include Hashie::Extensions::IndifferentAccess
6
+ include Hashie::Extensions::Dash::Coercion
7
+ include ActiveModel::Validations
8
+
9
+ def initialize(*args)
10
+ super(*args)
11
+ validate!
12
+ end
6
13
 
7
14
  property :ShipmentId, required: true
8
15
  property :BizId
@@ -85,10 +92,12 @@ module Snap
85
92
  property :OverdueInd
86
93
  property :Stage
87
94
  property :MaintInd
88
- property :ShipmentLines
95
+ property :ShipmentLines, coerce: Array[Models::ShipmentLine]
89
96
  property :ShipAddress
90
97
  property :ShipContacts
91
98
  property :ShipmentDespatch
99
+
100
+ validates :CustomerName, length: { maximum: 50 }
92
101
  end
93
102
  end
94
103
  end
@@ -0,0 +1,45 @@
1
+ module Snap
2
+ module Models
3
+ # A representation of a single ShipmentLine.
4
+ class ShipmentLine < Hashie::Dash
5
+ include Hashie::Extensions::IndifferentAccess
6
+
7
+ property :ShipmentId, required: true
8
+ property :Line
9
+ property :Level
10
+ property :SKUId, required: true
11
+ property :BizSKU
12
+ property :LineOwner
13
+ property :LineStockStatus
14
+ property :QtyOrdered, required: true
15
+ property :QtyRequired, required: true
16
+ property :QtyAllocated
17
+ property :QtyTasked
18
+ property :UnitOfMeasure, required: true
19
+ property :QtyPicked
20
+ property :QtyShipped
21
+ property :QtyDelivered
22
+ property :QtyDueOut
23
+ property :Price, required: true
24
+ property :Discount
25
+ property :TaxRate
26
+ property :SOLineId
27
+ property :ReturnReason
28
+ property :QC
29
+ property :Shortage
30
+ property :Variance
31
+ property :BOInd
32
+ property :ConsignmentId
33
+ property :PickGroupId
34
+ property :SiteId
35
+ property :Warehouse
36
+ property :BizId
37
+ property :OwnerId
38
+ property :StockStatus
39
+ property :DateShipment
40
+ property :AttachmentInd
41
+ property :SpecialConditionInd
42
+ property :Stage
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,12 @@
1
+ module Snap
2
+ module Models
3
+ # A representation of a Shipment Status.
4
+ class ShipmentStatus < Hashie::Dash
5
+ include Hashie::Extensions::IndifferentAccess
6
+
7
+ property :ShipmentId, required: true
8
+ property :Status, required: true
9
+ property :Stage
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'delegate'
2
+
3
+ module Snap
4
+ # Wraps HTTParty response so we can provide some helpful methods.
5
+ class Response < SimpleDelegator
6
+ def initialize(response, model)
7
+ @model = model
8
+ super(response)
9
+ end
10
+ attr_reader :model
11
+
12
+ def hydrate
13
+ model.new(to_hash)
14
+ end
15
+ end
16
+ end
data/lib/snap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Snap
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/snap.rb CHANGED
@@ -1,10 +1,16 @@
1
+ require 'active_model'
1
2
  require 'hashie'
2
3
  require 'httparty'
3
4
 
4
5
  require 'snap/version'
5
6
  require 'snap/client'
7
+ require 'snap/response'
6
8
 
9
+ require 'snap/api/shipment_status'
7
10
  require 'snap/api/shipments'
11
+
12
+ require 'snap/models/shipment_status'
13
+ require 'snap/models/shipment_line'
8
14
  require 'snap/models/shipment'
9
15
 
10
16
  # Top level module for the Snap gem.
data/snap.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  end
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency 'activemodel', '~> 5.1'
21
22
  spec.add_dependency 'hashie', '~> 3.5'
22
23
  spec.add_dependency 'httparty', '~> 0.16'
23
24
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snap-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-16 00:00:00.000000000 Z
11
+ date: 2018-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: hashie
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -185,9 +199,13 @@ files:
185
199
  - bin/setup
186
200
  - config/initializers/snap.rb
187
201
  - lib/snap.rb
202
+ - lib/snap/api/shipment_status.rb
188
203
  - lib/snap/api/shipments.rb
189
204
  - lib/snap/client.rb
190
205
  - lib/snap/models/shipment.rb
206
+ - lib/snap/models/shipment_line.rb
207
+ - lib/snap/models/shipment_status.rb
208
+ - lib/snap/response.rb
191
209
  - lib/snap/version.rb
192
210
  - snap.gemspec
193
211
  homepage: https://github.com/MeUndies/snap