iorwerth-hub 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
  SHA256:
3
- metadata.gz: 8fe7207839b271a72800dc05b9e9f8ed43b39208e765082e3272f548abc3035a
4
- data.tar.gz: 050fad5950fea4cec1f3d54fa4d2a5fa8a366331a9933ec514d42191bb3fec81
3
+ metadata.gz: d030b6a6a8d09a19eabfaa5d4de8f27682e144dfb968d3c05cbcb36359a334b8
4
+ data.tar.gz: 5f296810092251cb6de7e11b6edf527ba3069ffe649dd4a28d2b796d8f475641
5
5
  SHA512:
6
- metadata.gz: 0c66317ece2c5fb5413f8ea43d1627e29a2af29d0b9aa39f6f366a7a54e5f84704ec4f517561625eed63c166074a1dea9c666a6618b4596e188a85ec2b26cef8
7
- data.tar.gz: 987ca13d118419db3f8d9a9b11a35b87c96772388d5afd248f4e15526db858f634016781ec4b55fb4dd5d7ac4e01f5b7910e128d1f4f5798db9013570b6dc778
6
+ metadata.gz: 48155d512256d8a5147036ad71acb9142d78111df2a48e46a6866d588e128d274bf02be8e3bde04f9758d05d52bdd9b28fa396c32b07ba84cfce4b72d9fddfc1
7
+ data.tar.gz: 6fea37e940129be2dbc5a1907b109693dad63b867da00ebffb6fca2297502c8d882a60af19818de5d063cdd991ad804d3a321daf99c7f06e3af84d3211c9d63f
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 (unreleased)
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
+
10
+ ## 0.1.1
11
+
12
+ - Sign-in works against a Hub on plain http, such as the local one from
13
+ `docker compose --profile dev up`: discovery no longer assumes https.
14
+
15
+ ## 0.1.0
4
16
 
5
17
  - First release: `Iorwerth::Hub::Client` for every `/api/v1` operation, `entitled?` and
6
18
  `limit` with a cache that survives a Hub outage, `Webhook.verify` and a Rack
data/README.md CHANGED
@@ -40,6 +40,10 @@ HUB_API_KEY=...
40
40
  HUB_WEBHOOK_SECRET=...
41
41
  ```
42
42
 
43
+ To develop against a Hub on your own machine, see
44
+ [step 10 of the guide](../../docs/integration/connecting-a-product.md#10-test-locally):
45
+ `docker compose --profile dev up` prints a ready-made block for `.env.development`.
46
+
43
47
  You can override any of them in code:
44
48
 
45
49
  ```ruby
@@ -73,7 +77,9 @@ def callback
73
77
  auth = request.env["omniauth.auth"]
74
78
  user = User.find_or_initialize_by(hub_id: auth.uid)
75
79
  user.update!(email: auth.info.email, name: auth.info.name)
76
- 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|
77
83
  tenant = Tenant.find_or_create_by!(hub_organization_id: organization["id"])
78
84
  # ...
79
85
  end
@@ -87,6 +93,8 @@ hub = Iorwerth::Hub.client
87
93
  hub.get_organization("org_01J...") # profile, members, subscription, entitlements
88
94
  hub.report_tenant("org_01J...", external_tenant_id: tenant.id.to_s)
89
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"
90
98
  hub.invite("org_01J...", email: "sam@example.com", role: "member")
91
99
  hub.each_organization { |organization| ... } # every organization this product can see
92
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
@@ -36,6 +36,9 @@ module OmniAuth
36
36
  options.client_options.scheme = hub.scheme
37
37
  options.client_options.host = hub.host
38
38
  options.client_options.port = hub.port
39
+ # A Hub on a laptop (the Compose dev profile) is plain http, and discovery builds
40
+ # https URLs unless told otherwise. Production Hubs are https, so this never applies.
41
+ SWD.url_builder = URI::HTTP if hub.scheme == "http"
39
42
  end
40
43
 
41
44
  def request_phase
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Iorwerth
4
4
  module Hub
5
- VERSION = "0.1.0"
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.0
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.