mock_chargebee 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 41a40358cf8b7de396636263ce6343da7bff976d8a143b9c32601974673c475d
4
- data.tar.gz: 4df45ce97b0efcaeb150289b052861c0e037712e0b2cdf88078226d3d4a2b98f
3
+ metadata.gz: 8c4c4be5f02b98c87635fdbc94c8c9443abc2ec2de554436fe3f6a2803289535
4
+ data.tar.gz: 7a87c889ce9467bd63285473da59df46c6f78a76ff06877468a5fe00ba102bf2
5
5
  SHA512:
6
- metadata.gz: 30ba92494b7a80f9a775dc161e2cec20f6c6fd3fe4de7da38ebbe1365c2fffcfb61f69cddc351c68e1df1bc35e165eae03eb42ab382b3ec5ae008b6f2537db67
7
- data.tar.gz: 4d862d1fb78fff91f36c039dd3c4ea8ee79dfc6040501777bbcb2e227043c228fcf3e5d9b988c324107e1249d7f1ffc76ba43c92bc16f661cad552ad724ec6fb
6
+ metadata.gz: 47fc5f6ca550dfdec30a70d61773421d57398c748e5f1dbc2d588aa70ae31174f9ee62a0a0b360187dbde9ca7cdd771deecb38a1334515fab6a453dabe4362a0
7
+ data.tar.gz: 00c992d940924ad011e12d4612be7baa3765f9eb0b0bd42a142eae34dfbcaebc8cb46d6e25bfbb675795348ac65c1167a173c5409dc00504745e53fc81339d51
@@ -0,0 +1,20 @@
1
+ {
2
+ "access_url": "https://yourapp.chargebeeportal.com/portal/access/__test__cdBbQgJg5fPSTw9qBPDIaQiVEEx0Gsrrc",
3
+ "created_at": 1517505973,
4
+ "customer_id": "__test__KyVnHhSBWm8kA2sT",
5
+ "expires_at": 1517509573,
6
+ "id": "portal___test__KyVnHhSBWm8l82sV",
7
+ "linked_customers": [
8
+ {
9
+ "customer_id": "__test__KyVnHhSBWm8kA2sT",
10
+ "has_active_subscription": false,
11
+ "has_billing_address": false,
12
+ "has_payment_method": false,
13
+ "object": "linked_customer"
14
+ }
15
+ ],
16
+ "object": "portal_session",
17
+ "redirect_url": "https://yourdomain.com/users/3490343",
18
+ "status": "created",
19
+ "token": "__test__cdBbQgJg5fPSTw9qBPDIaQiVEEx0Gsrrc"
20
+ }
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MockChargebee
4
+ module Models
5
+ class PortalSession < Base
6
+ RESOURCE_ID_PREFIX = 'portal'
7
+
8
+ load_fixtures :portal_session
9
+
10
+ def self.create(params)
11
+ Validations::PortalSessions::CreateParams.validate_required(params)
12
+
13
+ params['id'] ||= unique_id
14
+ params['customer_id'] = params.dig(:customer, :id)
15
+ portal_session = portal_session_fixture.merge(params)
16
+ repositories.portal_sessions.store(portal_session['id'], portal_session)
17
+
18
+ portal_session
19
+ end
20
+ end
21
+ end
22
+ end
@@ -12,7 +12,8 @@ module MockChargebee
12
12
 
13
13
  add_repositories :customers,
14
14
  :subscriptions,
15
- :coupons
15
+ :coupons,
16
+ :portal_sessions
16
17
 
17
18
  class RepoHash < Hash
18
19
  def fetch(*)
@@ -6,12 +6,13 @@ module MockChargebee
6
6
  parsed_path = Util.parse_path_from_url(url)
7
7
  parsed_params = Util.parse_params(params)
8
8
 
9
- handler = RequestHandlers.const_get(parsed_path.resource.capitalize)
9
+ handler = RequestHandlers.const_get(parsed_path.resource.split('_').map(&:capitalize).join(''))
10
10
  resp = handler.call(method, parsed_path, parsed_params)
11
- resp = ChargeBee::Util.symbolize_keys(resp)
12
- resp
11
+ ChargeBee::Util.symbolize_keys(resp)
13
12
  rescue NameError => e
14
- raise MockChargebee::MissingRequestHandler parsed_path.resource if e.message.match?(/uninitialized constant #{parsed_path.resource.capitalize}/)
13
+ if e.message.match?(/uninitialized constant #{parsed_path.resource.capitalize}/)
14
+ raise MockChargebee::MissingRequestHandler parsed_path.resource
15
+ end
15
16
 
16
17
  raise e
17
18
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MockChargebee
4
+ module RequestHandlers
5
+ class PortalSession < Base
6
+ private
7
+
8
+ def post
9
+ portal_session = Models::PortalSession.create(params)
10
+ { portal_session: portal_session }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MockChargebee
4
+ module Validations
5
+ module PortalSessions
6
+ class CreateParams < Base
7
+ REQUIRED_KEYS = %w[customer].freeze
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MockChargebee
4
- VERSION = "0.0.3"
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_chargebee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cass
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,6 +110,7 @@ files:
110
110
  - lib/mock_chargebee/errors.rb
111
111
  - lib/mock_chargebee/fixtures/coupon.json
112
112
  - lib/mock_chargebee/fixtures/customer.json
113
+ - lib/mock_chargebee/fixtures/portal_session.json
113
114
  - lib/mock_chargebee/fixtures/subscription.json
114
115
  - lib/mock_chargebee/fixtures/subscription_cancel_response.json
115
116
  - lib/mock_chargebee/fixtures/subscription_create_response.json
@@ -208,17 +209,20 @@ files:
208
209
  - lib/mock_chargebee/models/base.rb
209
210
  - lib/mock_chargebee/models/coupon.rb
210
211
  - lib/mock_chargebee/models/customer.rb
212
+ - lib/mock_chargebee/models/portal_session.rb
211
213
  - lib/mock_chargebee/models/subscription.rb
212
214
  - lib/mock_chargebee/repositories.rb
213
215
  - lib/mock_chargebee/request.rb
214
216
  - lib/mock_chargebee/request_handlers/base.rb
215
217
  - lib/mock_chargebee/request_handlers/coupons.rb
216
218
  - lib/mock_chargebee/request_handlers/customers.rb
219
+ - lib/mock_chargebee/request_handlers/portal_sessions.rb
217
220
  - lib/mock_chargebee/request_handlers/subscriptions.rb
218
221
  - lib/mock_chargebee/services/apply_coupons.rb
219
222
  - lib/mock_chargebee/util.rb
220
223
  - lib/mock_chargebee/validations/base.rb
221
224
  - lib/mock_chargebee/validations/coupons.rb
225
+ - lib/mock_chargebee/validations/portal_sessions.rb
222
226
  - lib/mock_chargebee/validations/subscriptions.rb
223
227
  - lib/mock_chargebee/validations/webhooks.rb
224
228
  - lib/mock_chargebee/version.rb