zelf-sdk 1.0.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.
@@ -0,0 +1,57 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The creator_sync endpoints.
5
+ class CreatorSync
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Create Creator Sync. Add a creator's profile and posts to Zelf so their videos can
11
+ # be analyzed. Send the creator's `profile_url`. Zelf reads and stores the profile and
12
+ # the creator's own posts, which then appear in `creators.list` and `content.list`.
13
+ # Syncing is asynchronous. This method returns immediately with the sync at `status:
14
+ # SYNCING`. Poll `creator_sync.get` until `status` is `SUCCESS` or `FAILED`. Only the
15
+ # creator's own posts are synced. Reposts and posts they are tagged in are not. Synced
16
+ # content is not attached to your brand, so it does not appear in brand-scoped totals.
17
+ #
18
+ # Calls POST /api/v1/creator_sync/ (creator_sync.create).
19
+ def create(profile_url:)
20
+ body = {
21
+ "profile_url" => profile_url,
22
+ }.reject { |_, value| value.nil? }
23
+ envelope = @transport.request(:post, "/api/v1/creator_sync/", body: body)
24
+ Zelf.one(envelope, Models::CreatorSync, "CreatorSync")
25
+ end
26
+
27
+ # Get Creator Sync. Returns a single creator sync job identified by `id`, the value
28
+ # returned by `creator_sync.create` or reported by a vetting as `sync_job_id`. Poll it
29
+ # until `status` reports `SUCCESS` or `FAILED`.
30
+ #
31
+ # Calls GET /api/v1/creator_sync/{id}/ (creator_sync.get).
32
+ def get(id)
33
+ path_params = { "id" => id }
34
+ envelope = @transport.request(:get, "/api/v1/creator_sync/{id}/", path_params: path_params)
35
+ Zelf.one(envelope, Models::CreatorSync, "CreatorSync")
36
+ end
37
+
38
+ # List Creator Syncs. Returns creator sync jobs ordered newest first, each with its
39
+ # current `status`. Use it to monitor progress after `creator_sync.create`. Possible
40
+ # statuses are `SCHEDULED`, `SYNCING`, `SUCCESS` and `FAILED`. A job's `creator_id` is
41
+ # `null` until the creator has been resolved, and then corresponds to the `id` filter
42
+ # on `creators.list`. Syncs started by `creator_vetting` are listed here too; a
43
+ # vetting reports its own sync as `sync_job_id`.
44
+ #
45
+ # Calls GET /api/v1/creator_sync/ (creator_sync.list).
46
+ def list(page: nil, page_size: nil)
47
+ query = {
48
+ "page" => page,
49
+ "page_size" => page_size,
50
+ }.reject { |_, value| value.nil? }
51
+ envelope = @transport.request(:get, "/api/v1/creator_sync/", query: query)
52
+ path = @transport.resolve_path("/api/v1/creator_sync/".dup, {})
53
+ Zelf::Page.new(envelope, Models::CreatorSync, @transport, path, query)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,124 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The creator_vetting endpoints.
5
+ class CreatorVetting
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Get Creator Vetting Content Statistics. Returns aggregate totals (post count, views,
11
+ # engagement, earned media value, and unique creators) over the content tied to a
12
+ # creator vetting. Requires `vetting_id` (a vetting `id` from `creator_vetting.list`)
13
+ # and returns the same totals shape as `content.statistics`.
14
+ #
15
+ # Calls GET /api/v1/creator/vetting/contents/statistics/ (creator_vetting.content_statistics).
16
+ def content_statistics(vetting_id:)
17
+ query = {
18
+ "vetting_id" => vetting_id,
19
+ }.reject { |_, value| value.nil? }
20
+ envelope = @transport.request(:get, "/api/v1/creator/vetting/contents/statistics/", query: query)
21
+ Zelf.one(envelope, Models::ContentStatistics, "ContentStatistics")
22
+ end
23
+
24
+ # List Creator Vetting Content. Returns the content tied to a creator vetting, in the
25
+ # standard content shape. Use it to inspect the specific posts behind a vetting.
26
+ # Requires `vetting_id` (a vetting `id` from `creator_vetting.list`). Brand-scoped
27
+ # fields (`is_owned`, `is_tagged`, `net_promoter_score`, ...) are `null` in this
28
+ # response.
29
+ #
30
+ # Calls GET /api/v1/creator/vetting/contents/ (creator_vetting.contents).
31
+ def contents(vetting_id:, page: nil, page_size: nil)
32
+ query = {
33
+ "page" => page,
34
+ "page_size" => page_size,
35
+ "vetting_id" => vetting_id,
36
+ }.reject { |_, value| value.nil? }
37
+ envelope = @transport.request(:get, "/api/v1/creator/vetting/contents/", query: query)
38
+ path = @transport.resolve_path("/api/v1/creator/vetting/contents/".dup, {})
39
+ Zelf::Page.new(envelope, Models::Content, @transport, path, query)
40
+ end
41
+
42
+ # Create Creator Vetting. Vets a creator identified by `profile_url`, running or
43
+ # reusing the profile scrape and the AI safety and brand-fit analysis. Runs complete
44
+ # asynchronously, so this method returns immediately with the created vetting. The
45
+ # vetting analyzes up to 150 of the creator's posts per connection type, or the limit
46
+ # configured for your workspace. The created vetting is returned as the single item in
47
+ # `results`. Take its `id` and poll `creator_vetting.list` until a run reports
48
+ # `COMPLETED`. A vetting can take an hour or more to complete, so prefer the
49
+ # `creator_vetting.completed` webhook over frequent polling, which can trigger
50
+ # `RATE_LIMIT_EXCEEDED`. Once a run is complete, retrieve the payload from
51
+ # `creator_vetting.results`, passing `vetting_id=<id>`.
52
+ #
53
+ # Calls POST /api/v1/creator/vetting/ (creator_vetting.create).
54
+ def create(profile_url:, resync_profile: nil, content_scope: nil, safety_checks: nil)
55
+ body = {
56
+ "profile_url" => profile_url,
57
+ "resync_profile" => resync_profile,
58
+ "content_scope" => content_scope,
59
+ "safety_checks" => safety_checks,
60
+ }.reject { |_, value| value.nil? }
61
+ envelope = @transport.request(:post, "/api/v1/creator/vetting/", body: body)
62
+ Zelf.one(envelope, Models::CreatorVetting, "CreatorVetting")
63
+ end
64
+
65
+ # List Creator Vettings. Returns creator vettings ordered newest first, each with its
66
+ # analysis runs and their current `status`. Use it to discover vettings and monitor
67
+ # run progress without retrieving the full result payload. A vetting `id` corresponds
68
+ # to the `vetting_id` parameter on `creator_vetting.results` and
69
+ # `creator_vetting.contents`, and each run's `id` corresponds to the `id` parameter on
70
+ # `creator_vetting.results`. The run `result` download is not included in this
71
+ # response; retrieve it from `creator_vetting.results` once a run reports `COMPLETED`.
72
+ # Possible statuses are `IN_PROGRESS`, `COMPLETED`, `EMPTY_RESULT`, and `FAILED`.
73
+ # Supply `creator_id` to filter to a single creator, or `id` to return a single
74
+ # vetting.
75
+ #
76
+ # Calls GET /api/v1/creator/vetting/ (creator_vetting.list).
77
+ def list(creator_id: nil, id: nil, page: nil, page_size: nil)
78
+ query = {
79
+ "creator_id" => creator_id,
80
+ "id" => id,
81
+ "page" => page,
82
+ "page_size" => page_size,
83
+ }.reject { |_, value| value.nil? }
84
+ envelope = @transport.request(:get, "/api/v1/creator/vetting/", query: query)
85
+ path = @transport.resolve_path("/api/v1/creator/vetting/".dup, {})
86
+ Zelf::Page.new(envelope, Models::CreatorVetting, @transport, path, query)
87
+ end
88
+
89
+ # Get Creator Vetting Results. Returns the `result` for each run: a signed, time-
90
+ # limited download of the vetting analysis payload. Call this method after a run
91
+ # reaches `COMPLETED`; for earlier statuses the row is returned with a `null`
92
+ # `result`. Supply `vetting_id` (the vetting `id` from `creator_vetting.list`) to
93
+ # return every run of that vetting, or `id` (a single run's `id`) to return one run.
94
+ # One of the two is required. A malformed identifier returns `INVALID_ID`; omitting
95
+ # both returns `VALIDATION_ERROR`. **Disclosures.*; When the vetting requested
96
+ # `DISCLOSURE`, the payload's `insight_json.disclosures` holds one entry per analyzed
97
+ # video: its `content_id` and a `result`. The `result` lists `evidence` items, each
98
+ # with the `source` it was found in (`frame` for on-screen text, `audio` for the
99
+ # speech transcription, `title`, `caption` or `metadata`), a `kind` (`sponsorship`,
100
+ # `affiliate`, `gifted` or `relationship` for a commercial relationship; `terms` or
101
+ # `risk` for offer conditions and warnings), the quoted `text` and, where known,
102
+ # `time_seconds`. It also gives each source a `channels` status: `present`, `absent`
103
+ # or `unknown` (not checked). Disclosures are not counted as violations. Limits: only
104
+ # videos up to 10 minutes are checked; on-screen text is read from sampled frames, so
105
+ # text shown only briefly can be missed; videos ZelfAI analyzed before the request are
106
+ # not re-analyzed for disclosures. An empty `evidence` list does not confirm that a
107
+ # video has no disclosure. Detection reports what was stated; it does not assess legal
108
+ # compliance.
109
+ #
110
+ # Calls GET /api/v1/creator/vetting/results/ (creator_vetting.results).
111
+ def results(id: nil, page: nil, page_size: nil, vetting_id: nil)
112
+ query = {
113
+ "id" => id,
114
+ "page" => page,
115
+ "page_size" => page_size,
116
+ "vetting_id" => vetting_id,
117
+ }.reject { |_, value| value.nil? }
118
+ envelope = @transport.request(:get, "/api/v1/creator/vetting/results/", query: query)
119
+ path = @transport.resolve_path("/api/v1/creator/vetting/results/".dup, {})
120
+ Zelf::Page.new(envelope, Models::CreatorVettingResult, @transport, path, query)
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,33 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The creators endpoints.
5
+ class Creators
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # List Creators. Returns creators across the platforms Zelf supports. At least one of
11
+ # `id`, `username`, or `email` must be supplied to scope the search. Results can be
12
+ # ordered with `order_by` (`follower_count`, `id`). The `id` of each creator
13
+ # corresponds to the `creator_id` filter on `creator_vetting.list`. Requests that
14
+ # supply none of the required filters return `INVALID_ID`.
15
+ #
16
+ # Calls GET /api/v1/creator/ (creators.list).
17
+ def list(email: nil, id: nil, order_by: nil, page: nil, page_size: nil, platform: nil, username: nil)
18
+ query = {
19
+ "email" => email,
20
+ "id" => id,
21
+ "order_by" => order_by,
22
+ "page" => page,
23
+ "page_size" => page_size,
24
+ "platform" => platform,
25
+ "username" => username,
26
+ }.reject { |_, value| value.nil? }
27
+ envelope = @transport.request(:get, "/api/v1/creator/", query: query)
28
+ path = @transport.resolve_path("/api/v1/creator/".dup, {})
29
+ Zelf::Page.new(envelope, Models::Creator, @transport, path, query)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,89 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The detection endpoints.
5
+ class Detection
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Detect brands in a video. Detects a list of brands in one video. Zelf Detection
11
+ # reads the whole video and finds each scene where a brand is identifiable: its logo
12
+ # or name is visible (on a product, on packaging or in on-screen text) or the brand is
13
+ # named out loud. Every appearance (placement) comes back with its timestamp, what was
14
+ # detected and how confident the detection is. Send the brands in
15
+ # `context.hints.brands`. Identify the video with `content_id` (a video already in
16
+ # Zelf) or `content_url` (a link to any supported video). Sending both, or neither,
17
+ # returns `VALIDATION_ERROR`. A `content_url` that is not in Zelf yet is added first,
18
+ # which makes the detection take longer. **Limits*; ; One video per request, up to 90
19
+ # minutes. YouTube, TikTok and Instagram videos. Photo posts are not supported.; A
20
+ # product with no visible logo or name, and no spoken mention, is not detected.;
21
+ # `content_url`: the full video link, not a short link (`vm.tiktok.com`,
22
+ # `vt.tiktok.com`, `tiktok.com/t/`). Supported forms: `youtube.com/watch?v=<id>`,
23
+ # `youtu.be/<id>`, `youtube.com/shorts/<id>`, `tiktok.com/@<handle>/video/<id>`,
24
+ # `instagram.com/reel/<id>`, `/p/<id>`, `/tv/<id>`.; `context.hints.brands`: 1 to 200
25
+ # brands. No two names that differ only by punctuation or digits.;
26
+ # `context.hints.brands[].name`: up to 60 characters.;
27
+ # `context.hints.brands[].identifiers`: 2 to 10, each 2 to 200 characters, including
28
+ # the brand name.; `context.hints.brands[].negatives`: optional, up to 12, each up to
29
+ # 200 characters. A request that breaks a rule returns `VALIDATION_ERROR` for the
30
+ # first rule it breaks. `error.details.field` names the field, for example
31
+ # `context.hints.brands[3].identifiers`, and `error.details.code` is one of
32
+ # `INVALID_REQUEST`, `NO_BRANDS`, `TOO_MANY_BRANDS`, `INVALID_BRAND`,
33
+ # `IDENTIFIER_COUNT`, `IDENTIFIER_TOO_SHORT`, `UNSUPPORTED_URL`, `SHORT_LINK`,
34
+ # `PHOTO_POST` or `VIDEO_TOO_LONG`. Detection is asynchronous. This method returns
35
+ # immediately with the detection at `status: SCHEDULED`. Poll `detection.get` until
36
+ # `status` is `SUCCESS` or `FAILED`; both are final.
37
+ #
38
+ # Calls POST /api/v1/detection/ (detection.create).
39
+ def create(context:, content_id: nil, content_url: nil)
40
+ body = {
41
+ "context" => context,
42
+ "content_id" => content_id,
43
+ "content_url" => content_url,
44
+ }.reject { |_, value| value.nil? }
45
+ envelope = @transport.request(:post, "/api/v1/detection/", body: body)
46
+ Zelf.one(envelope, Models::Detection, "Detection")
47
+ end
48
+
49
+ # Retrieve a detection and its placements. Retrieve one detection by `id`, the value
50
+ # returned by `detection.create`. Poll it until `status` is `SUCCESS` or `FAILED`;
51
+ # both are final. `result` is `null` until then. On `FAILED`, `result` carries the
52
+ # counts and `brands: []`. **Reading `result`*; ; `brands`: one entry per requested
53
+ # brand, in request order. `found: false` means the brand was searched for and does
54
+ # not appear in the video.; `timestamp`: `mm:ss-mm:ss`, or `mm:ss` for a single
55
+ # moment. Past an hour the minutes keep counting (`69:23-69:25`).; `modality`:
56
+ # `Visual` (logo or product on screen), `Text` (brand name written on screen) or
57
+ # `Audio` (brand name spoken).; `confidence`: `confirmed` means the placement passed a
58
+ # final check against the video's frames; `review` means it was detected but did not
59
+ # pass that final frame check. `Audio` placements are always `review`, because a
60
+ # spoken mention has no frames to check. On `Visual` and `Text` placements, `review`
61
+ # means the final frame check did not confirm the placement.;
62
+ # `video_url_at_timestamp`: YouTube only, opens the video 5 seconds before the
63
+ # placement. `null` on TikTok and Instagram.
64
+ #
65
+ # Calls GET /api/v1/detection/{id}/ (detection.get).
66
+ def get(id)
67
+ path_params = { "id" => id }
68
+ envelope = @transport.request(:get, "/api/v1/detection/{id}/", path_params: path_params)
69
+ Zelf.one(envelope, Models::Detection, "Detection")
70
+ end
71
+
72
+ # List detections and their status. Lists detections, newest first. Each detection has
73
+ # its current `status` and, once finished, its placements in `result`. Possible
74
+ # statuses are `SCHEDULED`, `IN_PROGRESS`, `SUCCESS` and `FAILED`. `SUCCESS` and
75
+ # `FAILED` are final.
76
+ #
77
+ # Calls GET /api/v1/detection/ (detection.list).
78
+ def list(page: nil, page_size: nil)
79
+ query = {
80
+ "page" => page,
81
+ "page_size" => page_size,
82
+ }.reject { |_, value| value.nil? }
83
+ envelope = @transport.request(:get, "/api/v1/detection/", query: query)
84
+ path = @transport.resolve_path("/api/v1/detection/".dup, {})
85
+ Zelf::Page.new(envelope, Models::Detection, @transport, path, query)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,33 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The sub_brands endpoints.
5
+ class SubBrands
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Create Sub-brand. Creates a sub-brand under the workspace brand. A sub-brand tracks
11
+ # a competitor (`COMPETITIVE`) or a content theme (`THEME`) separately. A brand may
12
+ # have at most 64 sub-brands; requests beyond this limit are rejected. The new brand's
13
+ # `id` is the value to supply as `brand_id` elsewhere.
14
+ #
15
+ # Calls POST /api/v1/brands/ (sub_brands.create).
16
+ def create(title:, sub_brand_type:, search_terms: nil, inclusion_terms: nil, exclusion_terms: nil, compound_inclusion_terms: nil, influencer_terms: nil, allowed_languages: nil, boolean_query: nil)
17
+ body = {
18
+ "title" => title,
19
+ "sub_brand_type" => sub_brand_type,
20
+ "search_terms" => search_terms,
21
+ "inclusion_terms" => inclusion_terms,
22
+ "exclusion_terms" => exclusion_terms,
23
+ "compound_inclusion_terms" => compound_inclusion_terms,
24
+ "influencer_terms" => influencer_terms,
25
+ "allowed_languages" => allowed_languages,
26
+ "boolean_query" => boolean_query,
27
+ }.reject { |_, value| value.nil? }
28
+ envelope = @transport.request(:post, "/api/v1/brands/", body: body)
29
+ Zelf.one(envelope, Models::Brand, "Brand")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The usage endpoints.
5
+ class Usage
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Get Usage. Live consumption for your brand, per group and per window. Both sections
11
+ # come back however you call: `api` groups count requests made with an API key, `mcp`
12
+ # groups count the ones an AI client makes, and the two never share a counter.
13
+ # `authenticated_as` says which of them the current credentials spend. A window
14
+ # appears only when a limit is configured for it, so a brand with no monthly limit has
15
+ # no monthly row. Ask an administrator to set one and it appears here with no further
16
+ # work. `reset_in` counts down to the end of the current window, which starts on its
17
+ # first request rather than on the clock. Reading this consumes no quota.
18
+ #
19
+ # Calls GET /api/v1/usage/ (usage.retrieve).
20
+ def retrieve
21
+ envelope = @transport.request(:get, "/api/v1/usage/")
22
+ Zelf.one(envelope, Models::Usage, "Usage")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,199 @@
1
+ # Generated by codegen. Do not edit by hand.
2
+ module Zelf
3
+ module Resources
4
+ # The webhooks endpoints.
5
+ class Webhooks
6
+ def initialize(transport)
7
+ @transport = transport
8
+ end
9
+
10
+ # Create Webhook Secret. Creates a signing secret for the brand. The full `secret` is
11
+ # returned only once.
12
+ #
13
+ # Calls POST /api/v1/webhooks/secrets/ (webhooks.create_secret).
14
+ def create_secret(kind: nil, make_default: nil)
15
+ body = {
16
+ "kind" => kind,
17
+ "make_default" => make_default,
18
+ }.reject { |_, value| value.nil? }
19
+ envelope = @transport.request(:post, "/api/v1/webhooks/secrets/", body: body)
20
+ Zelf.one(envelope, Models::WebhookSecretCreated, "WebhookSecretCreated")
21
+ end
22
+
23
+ # Create Webhook Subscription. Creates a webhook subscription for your brand. The full
24
+ # signing `secret` is returned only once, in this response. A brand may hold at most
25
+ # one `event` subscription.
26
+ #
27
+ # Calls POST /api/v1/webhooks/subscriptions/ (webhooks.create_subscription).
28
+ def create_subscription(url:, kind: nil, resource: nil, event_types: nil, resource_filters: nil, custom_headers: nil, interval_hours: nil, max_items: nil, secret_type: nil)
29
+ body = {
30
+ "url" => url,
31
+ "kind" => kind,
32
+ "resource" => resource,
33
+ "event_types" => event_types,
34
+ "resource_filters" => resource_filters,
35
+ "custom_headers" => custom_headers,
36
+ "interval_hours" => interval_hours,
37
+ "max_items" => max_items,
38
+ "secret_type" => secret_type,
39
+ }.reject { |_, value| value.nil? }
40
+ envelope = @transport.request(:post, "/api/v1/webhooks/subscriptions/", body: body)
41
+ Zelf.one(envelope, Models::WebhookSubscriptionCreated, "WebhookSubscriptionCreated")
42
+ end
43
+
44
+ # Delete Webhook Secret. Deactivates a secret. The default secret, or one still linked
45
+ # to a subscription, cannot be deleted.
46
+ #
47
+ # Calls DELETE /api/v1/webhooks/secrets/{secret_id}/ (webhooks.delete_secret).
48
+ def delete_secret(secret_id)
49
+ path_params = { "secret_id" => secret_id }
50
+ envelope = @transport.request(:delete, "/api/v1/webhooks/secrets/{secret_id}/", path_params: path_params)
51
+ Zelf.one(envelope, Models::WebhookDeleteAcknowledgement, "WebhookDeleteAcknowledgement")
52
+ end
53
+
54
+ # Delete Webhook Subscription. Deletes a subscription. This is destructive: the
55
+ # subscription stops receiving deliveries.
56
+ #
57
+ # Calls DELETE /api/v1/webhooks/subscriptions/{subscription_id}/ (webhooks.delete_subscription).
58
+ def delete_subscription(subscription_id)
59
+ path_params = { "subscription_id" => subscription_id }
60
+ envelope = @transport.request(:delete, "/api/v1/webhooks/subscriptions/{subscription_id}/", path_params: path_params)
61
+ Zelf.one(envelope, Models::WebhookDeleteAcknowledgement, "WebhookDeleteAcknowledgement")
62
+ end
63
+
64
+ # Get Webhook Delivery. Returns a single delivery attempt.
65
+ #
66
+ # Calls GET /api/v1/webhooks/deliveries/{delivery_id}/ (webhooks.get_delivery).
67
+ def get_delivery(delivery_id)
68
+ path_params = { "delivery_id" => delivery_id }
69
+ envelope = @transport.request(:get, "/api/v1/webhooks/deliveries/{delivery_id}/", path_params: path_params)
70
+ Zelf.one(envelope, Models::WebhookDelivery, "WebhookDelivery")
71
+ end
72
+
73
+ # Get Webhook Secret. Returns a single secret.
74
+ #
75
+ # Calls GET /api/v1/webhooks/secrets/{secret_id}/ (webhooks.get_secret).
76
+ def get_secret(secret_id)
77
+ path_params = { "secret_id" => secret_id }
78
+ envelope = @transport.request(:get, "/api/v1/webhooks/secrets/{secret_id}/", path_params: path_params)
79
+ Zelf.one(envelope, Models::WebhookSecret, "WebhookSecret")
80
+ end
81
+
82
+ # Get Webhook Subscription. Returns a single subscription.
83
+ #
84
+ # Calls GET /api/v1/webhooks/subscriptions/{subscription_id}/ (webhooks.get_subscription).
85
+ def get_subscription(subscription_id)
86
+ path_params = { "subscription_id" => subscription_id }
87
+ envelope = @transport.request(:get, "/api/v1/webhooks/subscriptions/{subscription_id}/", path_params: path_params)
88
+ Zelf.one(envelope, Models::WebhookSubscription, "WebhookSubscription")
89
+ end
90
+
91
+ # List Webhook Deliveries. Lists webhook delivery attempts for the brand, newest
92
+ # first. Filter by `subscription` (masked id), `state`, and a `created_after` /
93
+ # `created_before` window.
94
+ #
95
+ # Calls GET /api/v1/webhooks/deliveries/ (webhooks.list_deliveries).
96
+ def list_deliveries(created: nil, created_after: nil, created_before: nil, page: nil, page_size: nil, sort_by: nil, state: nil, state_not: nil, subscription: nil)
97
+ query = {
98
+ "created" => created,
99
+ "created_after" => created_after,
100
+ "created_before" => created_before,
101
+ "page" => page,
102
+ "page_size" => page_size,
103
+ "sort_by" => sort_by,
104
+ "state" => state,
105
+ "state!" => state_not,
106
+ "subscription" => subscription,
107
+ }.reject { |_, value| value.nil? }
108
+ envelope = @transport.request(:get, "/api/v1/webhooks/deliveries/", query: query)
109
+ path = @transport.resolve_path("/api/v1/webhooks/deliveries/".dup, {})
110
+ Zelf::Page.new(envelope, Models::WebhookDelivery, @transport, path, query)
111
+ end
112
+
113
+ # List Available Webhook Events. Lists the event types an event subscription can
114
+ # listen for.
115
+ #
116
+ # Calls GET /api/v1/webhooks/events/ (webhooks.list_events).
117
+ def list_events
118
+ envelope = @transport.request(:get, "/api/v1/webhooks/events/")
119
+ Zelf.rows(envelope, Models::WebhookAvailableEvent)
120
+ end
121
+
122
+ # List Webhook Secrets. Lists the brand's active secrets.
123
+ #
124
+ # Calls GET /api/v1/webhooks/secrets/ (webhooks.list_secrets).
125
+ def list_secrets(page: nil, page_size: nil)
126
+ query = {
127
+ "page" => page,
128
+ "page_size" => page_size,
129
+ }.reject { |_, value| value.nil? }
130
+ envelope = @transport.request(:get, "/api/v1/webhooks/secrets/", query: query)
131
+ path = @transport.resolve_path("/api/v1/webhooks/secrets/".dup, {})
132
+ Zelf::Page.new(envelope, Models::WebhookSecret, @transport, path, query)
133
+ end
134
+
135
+ # List Webhook Subscriptions. Returns the webhook subscriptions owned by your brand,
136
+ # newest first.
137
+ #
138
+ # Calls GET /api/v1/webhooks/subscriptions/ (webhooks.list_subscriptions).
139
+ def list_subscriptions(page: nil, page_size: nil)
140
+ query = {
141
+ "page" => page,
142
+ "page_size" => page_size,
143
+ }.reject { |_, value| value.nil? }
144
+ envelope = @transport.request(:get, "/api/v1/webhooks/subscriptions/", query: query)
145
+ path = @transport.resolve_path("/api/v1/webhooks/subscriptions/".dup, {})
146
+ Zelf::Page.new(envelope, Models::WebhookSubscription, @transport, path, query)
147
+ end
148
+
149
+ # Rotate Webhook Subscription Secret. Mints a new signing secret for the subscription
150
+ # and returns the full `secret` once. Deliveries after this use the new secret.
151
+ #
152
+ # Calls POST /api/v1/webhooks/subscriptions/{subscription_id}/rotate_secret/ (webhooks.rotate_subscription_secret).
153
+ def rotate_subscription_secret(subscription_id)
154
+ path_params = { "subscription_id" => subscription_id }
155
+ envelope = @transport.request(:post, "/api/v1/webhooks/subscriptions/{subscription_id}/rotate_secret/", path_params: path_params)
156
+ Zelf.one(envelope, Models::WebhookSubscriptionCreated, "WebhookSubscriptionCreated")
157
+ end
158
+
159
+ # Send Test Webhook. Queues a test event to the subscription's URL so you can verify
160
+ # signing and parsing. Rate limited to 12 per hour per subscription. A disabled
161
+ # subscription is rejected.
162
+ #
163
+ # Calls POST /api/v1/webhooks/subscriptions/{subscription_id}/send_test/ (webhooks.send_test).
164
+ def send_test(subscription_id)
165
+ path_params = { "subscription_id" => subscription_id }
166
+ envelope = @transport.request(:post, "/api/v1/webhooks/subscriptions/{subscription_id}/send_test/", path_params: path_params)
167
+ nil
168
+ end
169
+
170
+ # Set Default Webhook Secret. Marks a secret as the brand's default for its kind.
171
+ #
172
+ # Calls POST /api/v1/webhooks/secrets/{secret_id}/set_default/ (webhooks.set_default_secret).
173
+ def set_default_secret(secret_id)
174
+ path_params = { "secret_id" => secret_id }
175
+ envelope = @transport.request(:post, "/api/v1/webhooks/secrets/{secret_id}/set_default/", path_params: path_params)
176
+ Zelf.one(envelope, Models::WebhookSecret, "WebhookSecret")
177
+ end
178
+
179
+ # Update Webhook Subscription. Partially updates a subscription's `url`,
180
+ # `custom_headers`, `resource_filters`, `interval_hours`, `max_items`, or `enabled`.
181
+ # `kind`, `resource`, and `event_types` are immutable after create.
182
+ #
183
+ # Calls PATCH /api/v1/webhooks/subscriptions/{subscription_id}/ (webhooks.update_subscription).
184
+ def update_subscription(subscription_id, url: nil, resource_filters: nil, custom_headers: nil, interval_hours: nil, max_items: nil, enabled: nil)
185
+ path_params = { "subscription_id" => subscription_id }
186
+ body = {
187
+ "url" => url,
188
+ "resource_filters" => resource_filters,
189
+ "custom_headers" => custom_headers,
190
+ "interval_hours" => interval_hours,
191
+ "max_items" => max_items,
192
+ "enabled" => enabled,
193
+ }.reject { |_, value| value.nil? }
194
+ envelope = @transport.request(:patch, "/api/v1/webhooks/subscriptions/{subscription_id}/", path_params: path_params, body: body)
195
+ Zelf.one(envelope, Models::WebhookSubscription, "WebhookSubscription")
196
+ end
197
+ end
198
+ end
199
+ end