iorwerth-hub 0.1.1 → 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
  SHA256:
3
- metadata.gz: fe00c674601d7abf791b03dda0dfc53104eb0f555c125060ebaa2634e5e3ccb6
4
- data.tar.gz: fee576c01b5f1a62b7057d696a19a5f8cb0f3411528bce182e817a8c8b61d462
3
+ metadata.gz: d030b6a6a8d09a19eabfaa5d4de8f27682e144dfb968d3c05cbcb36359a334b8
4
+ data.tar.gz: 5f296810092251cb6de7e11b6edf527ba3069ffe649dd4a28d2b796d8f475641
5
5
  SHA512:
6
- metadata.gz: 288a3cef72db3fac3c58d97de710dcc5aa40088d661d80fab1999d7790c0104e3c0f8df7e28f22ce989ba60c22743ac5d7dbe4f40d0f6e9e6fda60691cd77d0c
7
- data.tar.gz: 44121888f35a9809e5de9455a9a953fb9421836955dcb512a95c6db000cb1dd60583447ce7324fc0897a1aa994deb0e52bf9e5e63308831d4017c37ae0714596
6
+ metadata.gz: 48155d512256d8a5147036ad71acb9142d78111df2a48e46a6866d588e128d274bf02be8e3bde04f9758d05d52bdd9b28fa396c32b07ba84cfce4b72d9fddfc1
7
+ data.tar.gz: 6fea37e940129be2dbc5a1907b109693dad63b867da00ebffb6fca2297502c8d882a60af19818de5d063cdd991ad804d3a321daf99c7f06e3af84d3211c9d63f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - `checkout` and `portal`: Stripe Checkout and Customer Portal URLs for an organization.
6
+ `checkout` without `plan:` buys the plan the organization requested at signup.
7
+ - `list_plans` answers no longer carry `ends_on`, and `interval` is `month` or `year`:
8
+ the Hub has no seasonal plans (ADR-0010).
9
+
3
10
  ## 0.1.1
4
11
 
5
12
  - Sign-in works against a Hub on plain http, such as the local one from
data/README.md CHANGED
@@ -77,7 +77,9 @@ def callback
77
77
  auth = request.env["omniauth.auth"]
78
78
  user = User.find_or_initialize_by(hub_id: auth.uid)
79
79
  user.update!(email: auth.info.email, name: auth.info.name)
80
- Iorwerth::Hub.organizations(auth).each do |organization|
80
+ # Each has "type": "business" or "personal". A product whose customers are
81
+ # organizations provisions business ones; one for individuals, the personal one.
82
+ Iorwerth::Hub.organizations(auth).select { |o| o["type"] == "business" }.each do |organization|
81
83
  tenant = Tenant.find_or_create_by!(hub_organization_id: organization["id"])
82
84
  # ...
83
85
  end
@@ -91,6 +93,8 @@ hub = Iorwerth::Hub.client
91
93
  hub.get_organization("org_01J...") # profile, members, subscription, entitlements
92
94
  hub.report_tenant("org_01J...", external_tenant_id: tenant.id.to_s)
93
95
  hub.report_usage("org_01J...", usage: { teams: 7 })
96
+ hub.checkout("org_01J...", plan: "pro", success_url: done_url, cancel_url: billing_url)["url"]
97
+ hub.portal("org_01J...", return_url: billing_url)["url"] # "Manage billing"
94
98
  hub.invite("org_01J...", email: "sam@example.com", role: "member")
95
99
  hub.each_organization { |organization| ... } # every organization this product can see
96
100
  hub.each_event(since: last_event_id) { |event| ... } # catch up after downtime
@@ -23,6 +23,8 @@ module Iorwerth
23
23
  "get_organization" => [:get, "/api/v1/organizations/{organization_id}"],
24
24
  "get_entitlements" => [:get, "/api/v1/organizations/{organization_id}/entitlements"],
25
25
  "report_tenant" => [:post, "/api/v1/organizations/{organization_id}/tenant"],
26
+ "checkout" => [:post, "/api/v1/organizations/{organization_id}/checkout"],
27
+ "portal" => [:post, "/api/v1/organizations/{organization_id}/portal"],
26
28
  "get_usage" => [:get, "/api/v1/organizations/{organization_id}/usage"],
27
29
  "report_usage" => [:post, "/api/v1/organizations/{organization_id}/usage"],
28
30
  "invite" => [:post, "/api/v1/organizations/{organization_id}/invites"],
@@ -74,6 +76,19 @@ module Iorwerth
74
76
  idempotency_key: idempotency_key)
75
77
  end
76
78
 
79
+ # A Stripe Checkout page for one of this product's plans; without plan:, the one requested
80
+ # at signup. Redirect the customer to answer["url"].
81
+ def checkout(organization_id, success_url:, cancel_url:, plan: nil, idempotency_key: SecureRandom.uuid)
82
+ body = { plan: plan, success_url: success_url, cancel_url: cancel_url }.compact
83
+ call("checkout", organization_id: organization_id, body: body, idempotency_key: idempotency_key)
84
+ end
85
+
86
+ # A Stripe Customer Portal page: card, invoices, plan changes, cancellation.
87
+ def portal(organization_id, return_url:, idempotency_key: SecureRandom.uuid)
88
+ call("portal", organization_id: organization_id, body: { return_url: return_url },
89
+ idempotency_key: idempotency_key)
90
+ end
91
+
77
92
  def get_usage(organization_id)
78
93
  call("get_usage", organization_id: organization_id)
79
94
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Iorwerth
4
4
  module Hub
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iorwerth-hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iorwerth Technologies
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-02 00:00:00.000000000 Z
11
+ date: 2026-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Sign-in through the Hub (OmniAuth), its /api/v1 client, cached entitlement
14
14
  checks, and a Rack endpoint that verifies the Hub's webhooks.