waffo-pancake 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +112 -7
- data/lib/waffo/pancake/api/customer_actions.rb +55 -0
- data/lib/waffo/pancake/api/product_actions.rb +64 -0
- data/lib/waffo/pancake/api/promotion_actions.rb +39 -0
- data/lib/waffo/pancake/api/queries.rb +292 -0
- data/lib/waffo/pancake/api/store_actions.rb +64 -0
- data/lib/waffo/pancake/client.rb +74 -165
- data/lib/waffo/pancake/connection.rb +113 -0
- data/lib/waffo/pancake/customer_session.rb +55 -0
- data/lib/waffo/pancake/errors.rb +5 -3
- data/lib/waffo/pancake/requests.rb +91 -0
- data/lib/waffo/pancake/store_checkout.rb +41 -0
- data/lib/waffo/pancake/test_helpers.rb +28 -6
- data/lib/waffo/pancake/version.rb +1 -1
- data/lib/waffo/pancake.rb +1 -0
- metadata +10 -1
|
@@ -115,13 +115,13 @@ module Waffo
|
|
|
115
115
|
"expiresAt" => (Time.now + 2700).utc.iso8601 }
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
def cancel_subscription(order_id)
|
|
119
|
-
record(:cancel_subscription, order_id)
|
|
118
|
+
def cancel_subscription(order_id, **params)
|
|
119
|
+
record(:cancel_subscription, order_id, *optional(params))
|
|
120
120
|
change_status(order_id, "canceling")
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
def reactivate_subscription(order_id)
|
|
124
|
-
record(:reactivate_subscription, order_id)
|
|
123
|
+
def reactivate_subscription(order_id, **params)
|
|
124
|
+
record(:reactivate_subscription, order_id, *optional(params))
|
|
125
125
|
change_status(order_id, "active")
|
|
126
126
|
end
|
|
127
127
|
|
|
@@ -130,19 +130,41 @@ module Waffo
|
|
|
130
130
|
{}
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
-
def action(path, params)
|
|
134
|
-
record(:action, path, params)
|
|
133
|
+
def action(path, params = {}, **named)
|
|
134
|
+
record(:action, path, params.merge(named))
|
|
135
135
|
{}
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
+
# Recorded, then answers as this same fake, so a test reads every call from one list.
|
|
139
|
+
def customer(token, **options)
|
|
140
|
+
record(:customer, token, *optional(options))
|
|
141
|
+
self
|
|
142
|
+
end
|
|
143
|
+
|
|
138
144
|
def called?(name) = calls.any? { |call| call.first == name }
|
|
139
145
|
|
|
146
|
+
# Every other API method records its call and answers empty, so a new endpoint cannot be
|
|
147
|
+
# missing from the fake. Lists answer [], counts 0, reads nil, writes {}.
|
|
148
|
+
answers = API::Queries.empty_answers.merge(webhook_deliveries_count: 0)
|
|
149
|
+
api_methods = [API::CustomerActions, API::StoreActions, API::ProductActions, API::PromotionActions,
|
|
150
|
+
API::Queries].flat_map(&:public_instance_methods)
|
|
151
|
+
client_only = %i[issue_session_token create_authenticated_plan_change webhook_deliveries_count
|
|
152
|
+
create_onetime_order create_subscription_order]
|
|
153
|
+
(api_methods + client_only).uniq.reject { |name| method_defined?(name) }.each do |name|
|
|
154
|
+
define_method(name) do |*arguments, **params|
|
|
155
|
+
record(name, *arguments, *optional(params))
|
|
156
|
+
answers.fetch(name, {})
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
140
160
|
private
|
|
141
161
|
def record(name, *arguments)
|
|
142
162
|
calls << [name, *arguments]
|
|
143
163
|
raise fail_with if fail_with
|
|
144
164
|
end
|
|
145
165
|
|
|
166
|
+
def optional(params) = params.empty? ? [] : [params]
|
|
167
|
+
|
|
146
168
|
def change_status(order_id, status)
|
|
147
169
|
@orders[order_id.to_s]&.merge!("status" => status)
|
|
148
170
|
{ "orderId" => order_id, "status" => status }
|
data/lib/waffo/pancake.rb
CHANGED
|
@@ -4,6 +4,7 @@ require_relative "pancake/version"
|
|
|
4
4
|
require_relative "pancake/errors"
|
|
5
5
|
require_relative "pancake/keys"
|
|
6
6
|
require_relative "pancake/client"
|
|
7
|
+
require_relative "pancake/store_checkout"
|
|
7
8
|
require_relative "pancake/deprecation"
|
|
8
9
|
require_relative "pancake/webhook"
|
|
9
10
|
require_relative "pancake/webhook/event"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: waffo-pancake
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Good First Issue
|
|
@@ -41,13 +41,22 @@ files:
|
|
|
41
41
|
- lib/generators/waffo_pancake/install/templates/webhook_job.rb.tt
|
|
42
42
|
- lib/generators/waffo_pancake/install/templates/webhooks_controller.rb.tt
|
|
43
43
|
- lib/waffo/pancake.rb
|
|
44
|
+
- lib/waffo/pancake/api/customer_actions.rb
|
|
45
|
+
- lib/waffo/pancake/api/product_actions.rb
|
|
46
|
+
- lib/waffo/pancake/api/promotion_actions.rb
|
|
47
|
+
- lib/waffo/pancake/api/queries.rb
|
|
48
|
+
- lib/waffo/pancake/api/store_actions.rb
|
|
44
49
|
- lib/waffo/pancake/client.rb
|
|
45
50
|
- lib/waffo/pancake/configuration.rb
|
|
51
|
+
- lib/waffo/pancake/connection.rb
|
|
46
52
|
- lib/waffo/pancake/customer_portal_controller.rb
|
|
53
|
+
- lib/waffo/pancake/customer_session.rb
|
|
47
54
|
- lib/waffo/pancake/deprecation.rb
|
|
48
55
|
- lib/waffo/pancake/errors.rb
|
|
49
56
|
- lib/waffo/pancake/keys.rb
|
|
50
57
|
- lib/waffo/pancake/railtie.rb
|
|
58
|
+
- lib/waffo/pancake/requests.rb
|
|
59
|
+
- lib/waffo/pancake/store_checkout.rb
|
|
51
60
|
- lib/waffo/pancake/test_helpers.rb
|
|
52
61
|
- lib/waffo/pancake/version.rb
|
|
53
62
|
- lib/waffo/pancake/webhook.rb
|