expressly 2.0.35.rc1 → 2.1.0.rc1

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
  SHA1:
3
- metadata.gz: 4103e82f0b1096f42f20a733d4507d1d05a16511
4
- data.tar.gz: 572f5026e42d351e351c692a1be1a48a7cf738af
3
+ metadata.gz: 7fd45f6d990165a5a5c78853e51f465aa2d31b33
4
+ data.tar.gz: 8abf6111d847fb7ac908242dd7500b3ba9ba8468
5
5
  SHA512:
6
- metadata.gz: e7ec99bd385a22a22b86d3b5324fab7b90a14a26ae86f5b2a4698e3af9c3a64086e3533e475863f59e6c399e99025f49258197eb959cbdadfe2a6352c2a49095
7
- data.tar.gz: ce056d6097ab3b71b3f1a250604b81c57a3f845513aa6a7a7d3aaaef6867fdd5ddf3536bd893a45522b3ffd9c1738b2b6333db9db489ee9ec2d27322686f878e
6
+ metadata.gz: 3fca2dab19366b411754e975df3aeac5ab6f50220fd2d522d9435c7dc5ef6f1db1e3df1223108c13abfae9b80057bf2f85e6a6a9e80558eec512f386afe05c21
7
+ data.tar.gz: a36ff27710a7d95c6685fa708290c18f48e44833dbeac466ea9be5c9f23caf69f568f854011f3b649c1aa4fb848b1afb9d0b2af1b29012badd50b0eebefc8b95
@@ -1,8 +1,11 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.1.6
4
- - 2.2.2
5
-
6
- addons:
7
- code_climate:
8
- repo_token: 4b7cb0837c0bcb22501262f1c463f02f189dbb510001c68e2e498db0e80f24bb
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.1.6
4
+ - 2.2.2
5
+ addons:
6
+ code_climate:
7
+ repo_token: 4b7cb0837c0bcb22501262f1c463f02f189dbb510001c68e2e498db0e80f24bb
8
+ notifications:
9
+ hipchat:
10
+ rooms:
11
+ secure: a34ZhAhOnj1e+eZhQXDbFWZub6pUHNlnzAkk1c4aIVXTiGXshnON9lEI259ZkAFuVjNfQTlKHiuLBsWikpaWtzYFZhoKbNijRf1JTeClCI4gtlVN2/XI3HKVvRJXNqoeYxQ15MCIq/oFgIWMBRJucVeb9XkSO5O24QgPDaAuHiuIZTQNC2hHSjKek8eY9B1mwceQzxH8WUZiUo4MdFfVtWrHDaE+TPpso/6hcb1V9vPs17IIxBEr55nX2t3wXjvWNAvnk0A8AJcr2EZX7ORq0Ptn9pYW9uHTf+hQT6Qz+ZPrAjOubZSGjYHN/CH3jRUHbFY7f0ONZQxnA0A+3RgIPHx1fStt7cbPTbKSc+T7/Otxf8wOMyuv/NyHLqjPwd3LUHUwCi3MntrP55cP6m1dKu9yCc7C6GxFpiI7mjAog/VTxdxaeUk+A6UT8ZYhNzey8tCbx9SxioLOI2RyKpYduFle5MGDpAENldiThypRVuOUj8s/IH5s+KNS1bALOObFNi34/jcczF55UA3/yYkhpDEln6JXD3MH+AVEDLIQvTBkMyn3yhYst/Yn4TDJjWC3mqxDN7niJcVCUaGRJx1uqj97WD0UUI1jhqspWEvO1qtq039TE5B8PBAHUcYfNo9alLvBt0b422Yu0gzwryBtscJB/PIUxkkndfXlMy/gqWk=
@@ -1,4 +1,4 @@
1
- {<img src="https://buyexpressly.com/assets/img/expressly-logo-sm-gray.png" alt="Expressly" />}[https://buyexpressly.com]
1
+ {<img src="http://developer.buyexpressly.com/img/expressly-logo-sm-gray.png" alt="Expressly" />}[https://buyexpressly.com]
2
2
 
3
3
  = Expressly Plug-in Ruby SDK
4
4
 
@@ -5,19 +5,23 @@ module Expressly
5
5
  before_action :authenticate
6
6
  skip_before_action :authenticate, only: [:display_popup, :migrate]
7
7
 
8
- def ping
9
- render content_type: "application/json", json: { "expressly" => "Stuff is happening!" }
10
- end
11
-
12
- def ping_registered
13
- render content_type: "application/json", json: { "registered" => true }
8
+ def registered
9
+ render content_type: "application/json", json: {
10
+ :registered => true,
11
+ :version => 'V2',
12
+ :lightbox => 'javascript',
13
+ :platformName => 'ExpresslyRubySdk',
14
+ :platformVersion => Expressly::Version::STRING
15
+ }
14
16
  end
15
17
 
16
18
  def customer_export
19
+ customer = provider.get_customer(params[:email]) or raise ActionController::RoutingError.new('Not Found')
20
+
17
21
  result = Expressly::CustomerExport.new({
18
22
  :metadata => config.merchant_metadata,
19
23
  :primary_email => params[:email],
20
- :customer => provider.get_customer(params[:email])
24
+ :customer => customer
21
25
  })
22
26
  render content_type: "application/json", json: JSON.parse(result.to_json)
23
27
  end
@@ -32,31 +36,19 @@ module Expressly
32
36
  render content_type: "application/json", json: result
33
37
  end
34
38
 
35
- def display_popup
36
- provider.popup_handler(self, params[:campaign_customer_uuid])
37
- end
38
-
39
39
  def migrate
40
40
  campaign_customer_uuid = params[:campaign_customer_uuid]
41
41
  begin
42
-
43
42
  import = config.expressly_provider.fetch_customer_data(campaign_customer_uuid)
44
43
  customer_reference = provider.customer_register(import.primary_email, import.customer)
45
44
  provider.customer_send_password_reset_email(customer_reference)
46
- provider.customer_update_cart(customer_reference, import.cart)
47
- provider.customer_login(customer_reference)
48
- redirect_to provider.customer_migrated_redirect_url(true, customer_reference)
49
-
50
- begin
51
- config.expressly_provider.confirm_migration_success?(campaign_customer_uuid)
52
- rescue StandardError => e
53
- Expressly::logger.warn(self) {
54
- "couldn't finalise migration campaign_customer_uuid=[#{campaign_customer_uuid}], email=[#{import.primary_email}], error=[#{e.message}]"
55
- }
45
+ unless import.cart.nil?
46
+ provider.customer_update_cart(customer_reference, import.cart)
56
47
  end
48
+ provider.customer_login(customer_reference)
49
+ redirect_to "#{config.expressly_endpoint}/redirect/migration/#{campaign_customer_uuid}/success"
57
50
  rescue Expressly::ExpresslyError
58
- # already migrated or invalid uuid so just redirect
59
- redirect_to provider.customer_migrated_redirect_url(false)
51
+ redirect_to "#{config.expressly_endpoint}/redirect/migration/#{campaign_customer_uuid}/failed"
60
52
  end
61
53
  end
62
54
 
@@ -1,11 +1,7 @@
1
1
  Rails.application.routes.draw do
2
- get 'expressly/api/ping'
3
- get 'expressly/api/ping_registered'
4
- get 'expressly/api/user/:email' => 'expressly/api#customer_export'
5
-
6
- post 'expressly/api/batch/invoice' => 'expressly/api#invoices'
2
+ get 'expressly/api/registered'
3
+ get 'expressly/api/user/:email' => 'expressly/api#customer_export', :constraints => { :email => /[^\/]+/ }
4
+ post 'expressly/api/batch/invoice' => 'expressly/api#invoices'
7
5
  post 'expressly/api/batch/customer' => 'expressly/api#check_emails'
8
-
9
6
  get 'expressly/api/:campaign_customer_uuid/migrate' => 'expressly/api#migrate'
10
- get 'expressly/api/:campaign_customer_uuid' => 'expressly/api#display_popup'
11
7
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Expressly::Version::STRING
8
8
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Marc G. Smith"]
10
- s.date = "2015-12-01"
10
+ s.date = "2017-04-11"
11
11
  s.description = "Expressly sdk to help with implementing the expressly e-commerce plug-in / module API"
12
12
  s.email = "marc@buyexpressly.com"
13
13
  s.extra_rdoc_files = [
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.homepage = "http://developer.buyexpressly.com"
20
20
  s.licenses = ["MIT"]
21
21
  s.require_paths = ["lib"]
22
- s.rubygems_version = "2.0.2"
22
+ s.rubygems_version = "2.6.11"
23
23
  s.summary = "Expressly plug-in sdk"
24
24
 
25
25
  s.add_development_dependency(%q<bundler>, ["~> 0"])
@@ -52,7 +52,7 @@ module Expressly
52
52
  @merchant_plugin_provider = merchant_plugin_provider
53
53
  @merchant_plugin_endpoint = merchant_plugin_endpoint
54
54
  @expressly_endpoint = expressly_endpoint
55
- @expressly_provider = Api.new(api_key, expressly_endpoint)
55
+ @expressly_provider = Api.new(@api_key, expressly_endpoint)
56
56
  @merchant_metadata = merchant_metadata
57
57
  end
58
58
  end
@@ -8,33 +8,6 @@ module Expressly
8
8
  @endpoint = endpoint
9
9
  end
10
10
 
11
- def ping?
12
- response = execute('/v1/merchant/ping', 'GET')
13
- JSON.parse(response.body)['success']
14
- end
15
-
16
- def install(base_url)
17
- api_key = Base64.strict_encode64("#{@merchant_uuid}:#{@secret_key}")
18
- execute(
19
- '/v2/plugin/merchant',
20
- 'POST',
21
- "{\"apiBaseUrl\":\"#{base_url}\", \"apiKey\":\"#{api_key}\"}")
22
- end
23
-
24
- def uninstall?
25
- response = execute(
26
- "/v2/plugin/merchant/#{@merchant_uuid}",
27
- 'DELETE')
28
- JSON.parse(response.body)['success']
29
- end
30
-
31
- def fetch_migration_confirmation_html(campaign_customer_uuid)
32
- response = execute(
33
- "/v2/migration/#{campaign_customer_uuid}",
34
- 'GET')
35
- response.body
36
- end
37
-
38
11
  def fetch_customer_data(campaign_customer_uuid)
39
12
  response = execute(
40
13
  "/v2/migration/#{campaign_customer_uuid}/user",
@@ -42,14 +15,9 @@ module Expressly
42
15
  CustomerImport.from_json(JSON.parse(response.body))
43
16
  end
44
17
 
45
- def confirm_migration_success?(campaign_customer_uuid)
46
- response = execute(
47
- "/v2/migration/#{campaign_customer_uuid}/success",
48
- 'POST')
49
- JSON.parse(response.body)['success']
50
- end
18
+ def execute(method_uri, http_verb, body = nil, limit = 4)
19
+ raise 'too many HTTP redirects' if limit == 0
51
20
 
52
- def execute(method_uri, http_verb, body = nil)
53
21
  uri = URI.parse("#{@endpoint}#{method_uri}")
54
22
  http = Net::HTTP.new(uri.host, uri.port)
55
23
  http.use_ssl = @endpoint.start_with?('https')
@@ -70,11 +38,15 @@ module Expressly
70
38
 
71
39
  response = http.request(request)
72
40
 
73
- if response.code.to_i >= 300
74
- handle_error(response)
41
+ case response
42
+ when Net::HTTPSuccess then
43
+ response
44
+ when Net::HTTPRedirection then
45
+ location = response['location']
46
+ execute(location, http_verb, body,limit - 1)
47
+ else
48
+ handle_error(response)
75
49
  end
76
-
77
- response
78
50
  end
79
51
 
80
52
  def handle_error(response)
@@ -427,9 +427,9 @@ module Expressly
427
427
  def add_order(order)
428
428
  order.freeze
429
429
  @orders << order
430
- @pre_tax_total += order.pre_tax_total.to_f
431
- @post_tax_total += order.post_tax_total.to_f
432
- @tax += order.tax.to_f
430
+ @pre_tax_total += (order.pre_tax_total.to_f * 100).round / 100.0
431
+ @post_tax_total += (order.post_tax_total.to_f * 100).round / 100.0
432
+ @tax += (order.tax.to_f * 100).round / 100.0
433
433
  end
434
434
 
435
435
  def to_json(_state = nil)
@@ -471,9 +471,9 @@ module Expressly
471
471
  :itemCount => @item_count.to_i,
472
472
  :coupon => @coupon_code,
473
473
  :currency => @currency,
474
- :preTaxTotal => @pre_tax_total.to_f,
475
- :postTaxTotal => @post_tax_total.to_f,
476
- :tax => @tax.to_f})
474
+ :preTaxTotal => (@pre_tax_total.to_f * 100).round / 100.0,
475
+ :postTaxTotal => (@post_tax_total.to_f * 100).round / 100.0,
476
+ :tax => (@tax.to_f * 100).round / 100.0})
477
477
  end
478
478
  end
479
479
 
@@ -8,33 +8,6 @@ module Expressly
8
8
  class MerchantPluginProvider
9
9
  include AbstractInterface
10
10
 
11
- ##
12
- # The popup_handler is called when a prospective customer has clicked on a campaign promotion
13
- # and been directed to your shop. You are required to make a call to retrieve the expressly popup html
14
- # and embed it on the landing page of your choice.
15
- #
16
- # The typical flow would be:
17
- #
18
- # 1. customer clicks a promotion link to https://yourshop.com/expressly/api/:campaign_customer_uuid
19
- # 2. ApiController call popup_handler with itself as the first parameter and the uuid as the second parameter
20
- # 3. The handler should through a mechanism of their choice should display an appropriate page on their site and embed the Expressly popup HTML
21
- #
22
- # The mechanics of how to acheive step 3 is up to the implementer. The Expressly popup HTML is retrieved with the following call:
23
- # Expressly::default_configuration.expressly_provider.fetch_migration_confirmation_html(campaign_customer_uuid)
24
- #
25
- # === Args
26
- #
27
- # * +controller+ - an ApplicationController instance
28
- # * +campaign_customer_uuid+ - the Expressly uuid identifying the customer to be migrated
29
- #
30
- # === Return
31
- #
32
- # N/A
33
- #
34
- def popup_handler(controller, campaign_customer_uuid)
35
- MerchantPluginProvider.api_not_implemented(self)
36
- end
37
-
38
11
  ##
39
12
  # The customer register is the first step of the migration process after they have confirmed that they want to proceed.
40
13
  # You should register the customer on you system when you receive this call. You should treat this as a new customer,
@@ -101,23 +74,6 @@ module Expressly
101
74
  MerchantPluginProvider.api_not_implemented(self)
102
75
  end
103
76
 
104
- ##
105
- # Once the customer is migrated they will need to be re-directed to the most appropriate location on your site.
106
- # This could be the home page or the checkout.
107
- #
108
- # === Args
109
- #
110
- # * +success+ - if true then the customer was successfully migrated, if false then it failed and customer_reference will be nil
111
- # * +customer_reference+ - the reference you returned in the customer_register call unless the migration failed, in which case it will be nil
112
- #
113
- # === Return
114
- #
115
- # N/A
116
- #
117
- def customer_migrated_redirect_url(success, customer_reference)
118
- MerchantPluginProvider.api_not_implemented(self)
119
- end
120
-
121
77
  ##
122
78
  # The provider should respond to this call by populating an Expressly::Customer instance with the details of
123
79
  # the customer that matches the email address passed to it.
@@ -1,8 +1,8 @@
1
1
  module Expressly
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
5
- PATCH = 35
4
+ MINOR = 1
5
+ PATCH = 0
6
6
  BUILD = 'rc1'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -10,30 +10,6 @@ module Expressly
10
10
 
11
11
  describe "Api" do
12
12
 
13
- it "can ping" do
14
- FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
15
- :body => '{"success":true,"msg":"61c8c55e-9365-11e5-ac6c-281878baaac8"}')
16
- api.ping?.should == true
17
- end
18
-
19
- it "it can install" do
20
- FakeWeb.register_uri(:post, "http://#{api_key}@localhost:8080/api/v2/plugin/merchant",
21
- :status => ["204", "No Content"])
22
- api.install("http://localhost:3000")
23
- end
24
-
25
- it "it can uninstall" do
26
- FakeWeb.register_uri(:delete, "http://#{api_key}@localhost:8080/api/v2/plugin/merchant/#{merchant_uuid}",
27
- :body => '{"success":true,"msg":"Merchant uninstalled"}')
28
- api.uninstall?.should == true
29
- end
30
-
31
- it "it can fetch poup html" do
32
- FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}",
33
- :body => '<b>pop</b>')
34
- response = api.fetch_migration_confirmation_html(campaign_customer_uuid)
35
- response.should == '<b>pop</b>'
36
- end
37
13
 
38
14
  it "it can fetch customer data" do
39
15
  FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}/user",
@@ -71,15 +47,8 @@ module Expressly
71
47
  customer_import.customer.address_list[0].country.should == 'GB'
72
48
  end
73
49
 
74
- it "it can report the migration was successful" do
75
- FakeWeb.register_uri(:post, "http://#{api_key}@localhost:8080/api/v2/migration/#{campaign_customer_uuid}/success",
76
- :body => '{"success":true,"msg":"User registered as migrated"}')
77
- response = api.confirm_migration_success?(campaign_customer_uuid)
78
- response.should == true
79
- end
80
-
81
50
  it "it can parse the expressly error payload" do
82
- FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
51
+ FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/xxxx/user",
83
52
  :status => ["400", "Bad Request"],
84
53
  :content_type => "application/json",
85
54
  :body => '{' +
@@ -90,7 +59,7 @@ module Expressly
90
59
  '"causes":["cause"],' +
91
60
  '"actions":["action"]}')
92
61
  begin
93
- api.ping?
62
+ api.fetch_customer_data('xxxx')
94
63
  rescue ExpresslyError => e
95
64
  e.id.should == 'tid'
96
65
  e.message.should == 'Bad Request'
@@ -102,11 +71,11 @@ module Expressly
102
71
  end
103
72
 
104
73
  it "if it can parse the expressly error payload it will throw an http error" do
105
- FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v1/merchant/ping",
74
+ FakeWeb.register_uri(:get, "http://#{api_key}@localhost:8080/api/v2/migration/xxxx/user",
106
75
  :status => ["400", "Bad Request"],
107
76
  :body => 'WOW')
108
77
  begin
109
- api.ping?
78
+ api.fetch_customer_data('xxxx')
110
79
  rescue HttpError => e
111
80
  e.code.should == "400"
112
81
  e.body.should == 'WOW'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressly
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.35.rc1
4
+ version: 2.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc G. Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: 1.3.1
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.4.5.1
139
+ rubygems_version: 2.6.11
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Expressly plug-in sdk