shoppe-easypost 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76c41756705c9edcf4169659b9fa802c59f3b1fc
4
- data.tar.gz: be6e573e10a3dcf65d721bd1fbb04c040e8c8ed6
3
+ metadata.gz: 71894acc752c63b9406e211a34567193821f9f58
4
+ data.tar.gz: 2bc77b9845cebd6933e7514f828629e0d8291cba
5
5
  SHA512:
6
- metadata.gz: a6f23c0382fde802ec88c0ca693b3f8fa2defd43315137eff935fdf4e58269c12817a9d35f3abf5a0ef290b3661364de9417594c8ddfdc22fd965fde8b0846e7
7
- data.tar.gz: 429e8250574471028a70f152066cf8083858d3ba11338f43f7a67e315522d03abbb41e66040702a13ee70059d57433d689da72eefc79c872c41b489000bb6f8d
6
+ metadata.gz: 2a8e52bba6ef26f699525152a39c0649f8d26b9a08cd2d70e3f3dc238d5b4674d0bfdce3bcf83b4d2c62baa567dcb537965b3a2ae5a111c498f89157a488f684
7
+ data.tar.gz: 31bfc39c5a235edc9eb949f058715682eec27397e1ad7b63e1cc4645303b02eb6e58e84c4222f11a45fb377cf7ae3b9d048d2a8cbacef5eae62fce90aebc6214
@@ -0,0 +1,12 @@
1
+ en:
2
+ shoppe:
3
+ settings:
4
+ easypost: EasyPost
5
+ labels:
6
+ easypost_api_key: Live Secret API Key
7
+ easypost_shipping_options: Offered Shipping Options
8
+ handling_cost: Packaging and Handling Cost
9
+
10
+ help:
11
+ easypost_api_key: This is the Live Secret API key from https://www.easypost.com/account/keys.
12
+ easypost_shipping_options: This is a comma separated list of shipping options you'd like to be available to your customers. Use the service levels listed at https://www.easypost.com/service-levels-and-parcels.
@@ -1,6 +1,8 @@
1
1
  require "shoppe/easypost/version"
2
2
  require "shoppe/easypost/engine"
3
3
 
4
+ require "EasyPost"
5
+
4
6
  module Shoppe
5
7
  module Easypost
6
8
 
@@ -10,12 +12,48 @@ module Shoppe
10
12
  Shoppe.settings.easypost_api_key
11
13
  end
12
14
 
13
- def setup
14
- # Setup configuration with API key. Shipping options separated by commas.
15
- Shoppe.add_settings_group :easypost, [:easypost_api_key, :easypost_shipping_options]
15
+ def create_shipment(to_address, from_address, parcel)
16
+ EasyPost.api_key = self.api_key
17
+
18
+ EasyPost::Shipment.create(
19
+ {
20
+ to_address: to_address,
21
+ from_address: from_address,
22
+ parcel: parcel
23
+ }
24
+ )
25
+ end
26
+
27
+ def allowed_shipping_options
28
+ option_codes = []
29
+ Shoppe::DeliveryService.all.each do |ds|
30
+ option_codes << ds.code
31
+ end
32
+
33
+ option_codes
34
+ end
35
+
36
+ def available_options_and_rates(shipment)
37
+ available_rates = []
38
+ shipment.rates.each do |rate|
39
+ if self.allowed_shipping_options.include? rate.service
40
+ available_rates << rate
41
+ end
42
+ end
43
+
44
+ available_rates
45
+ end
16
46
 
17
- require "EasyPost"
47
+ def shipping_and_handling_costs(rates)
48
+ rates.each do |rate|
49
+ puts rate.rate.to_f + Shoppe.settings.handling_cost.to_f
50
+ end
18
51
  end
19
52
 
53
+ def setup
54
+ # Setup configuration with API key. Shipping options separated by commas.
55
+ Shoppe.add_settings_group :easypost, [:easypost_api_key, :handling_cost]
56
+ end
57
+ end
20
58
  end
21
59
  end
@@ -1,6 +1,9 @@
1
1
  module Shoppe
2
2
  module Easypost
3
- class Engine < ::Rails::Engine
3
+ class Engine < Rails::Engine
4
+ initializer "shoppe.easypost.initializer" do
5
+ Shoppe::Easypost.setup
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -1,5 +1,5 @@
1
1
  module Shoppe
2
2
  module Easypost
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoppe-easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Koumentis