kit-rb 0.4.0 → 0.5.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.
data/sig/kit-rb.rbs CHANGED
@@ -168,6 +168,40 @@ module Kit
168
168
  def call: (String current_access_token) -> String?
169
169
  end
170
170
 
171
+ # ActiveSupport::Notifications-compatible: `instrument(name, payload) { }`.
172
+ interface _Instrumenter
173
+ def instrument: (String name, Hash[Symbol, untyped] payload) { (Hash[Symbol, untyped]) -> untyped } -> untyped
174
+ end
175
+
176
+ # Anything with a Logger-like #debug (block or message form).
177
+ interface _Logger
178
+ def debug: (?untyped message) ?{ () -> untyped } -> untyped
179
+ end
180
+
181
+ module Instrumentation
182
+ EVENT: String
183
+ def self.around: (_Instrumenter? instrumenter, Symbol method, String path, Integer retries) { () -> [Integer, untyped] } -> [Integer, untyped]
184
+ def self.new_payload: (Symbol method, String path, Integer retries) -> Hash[Symbol, untyped]
185
+ def self.record_error: (Hash[Symbol, untyped] payload, Error error) -> void
186
+ def self.build: (?instrumenter: _Instrumenter?, ?logger: _Logger?) -> _Instrumenter?
187
+
188
+ class LoggerInstrumenter
189
+ def initialize: (_Logger logger) -> void
190
+ def instrument: (String name, Hash[Symbol, untyped] payload) { (Hash[Symbol, untyped]) -> untyped } -> untyped
191
+ end
192
+
193
+ class Multi
194
+ def initialize: (Array[_Instrumenter] instrumenters) -> void
195
+ def instrument: (String name, Hash[Symbol, untyped] payload) { (Hash[Symbol, untyped]) -> untyped } -> untyped
196
+ end
197
+ end
198
+
199
+ module TagNames
200
+ def self.normalize: (untyped name) -> String
201
+ def self.key: (untyped name) -> String
202
+ def self.distinct: (untyped names) -> Array[String]
203
+ end
204
+
171
205
  class Configuration
172
206
  attr_reader auth: (Auth::ApiKey | Auth::OAuth)
173
207
  attr_reader base_url: String
@@ -178,7 +212,8 @@ module Kit
178
212
  attr_reader retry_backoff: Float
179
213
  attr_reader max_backoff: Numeric
180
214
  attr_reader renew: _Renewer?
181
- def initialize: (?api_key: String?, ?access_token: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer, ?max_retries: Integer, ?retry_backoff: Float, ?max_backoff: Numeric, ?renew: _Renewer?) -> void
215
+ attr_reader instrumenter: _Instrumenter?
216
+ def initialize: (?api_key: String?, ?access_token: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer, ?max_retries: Integer, ?retry_backoff: Float, ?max_backoff: Numeric, ?renew: _Renewer?, ?instrumenter: _Instrumenter?, ?logger: _Logger?) -> void
182
217
  end
183
218
 
184
219
  class Connection
@@ -671,7 +706,7 @@ module Kit
671
706
 
672
707
  class Client
673
708
  attr_reader config: Configuration
674
- def initialize: (?api_key: String?, ?access_token: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer, ?max_retries: Integer, ?retry_backoff: Float, ?max_backoff: Numeric, ?renew: _Renewer?) -> void
709
+ def initialize: (?api_key: String?, ?access_token: String?, ?base_url: String, ?open_timeout: Integer, ?read_timeout: Integer, ?write_timeout: Integer, ?max_retries: Integer, ?retry_backoff: Float, ?max_backoff: Numeric, ?renew: _Renewer?, ?instrumenter: _Instrumenter?, ?logger: _Logger?) -> void
675
710
  def account: () -> Resources::Account
676
711
  def subscribers: () -> Resources::Subscribers
677
712
  attr_reader tags: Resources::Tags
@@ -689,3 +724,91 @@ module Kit
689
724
  def bulk: () -> Resources::Bulk
690
725
  end
691
726
  end
727
+
728
+ module Kit
729
+ # require "kit/testing" — consumer test support (not loaded by kit-rb).
730
+ module Testing
731
+ OPERATIONS: Hash[Symbol, [Symbol, String]]
732
+ OBJECTS: Hash[Symbol, Symbol]
733
+ FIXTURES_PATH: String
734
+ FIXTURES: Hash[String, Hash[String, untyped]]
735
+ KNOWN_FIELDS: Hash[String, Set[String]]
736
+
737
+ module Fixtures
738
+ PATH: String
739
+ ALL: Hash[String, Hash[String, untyped]]
740
+ KNOWN_FIELDS: Hash[String, Set[String]]
741
+ def self.for: (Symbol | String operation) -> Hash[String, untyped]
742
+ def self.status_for: (Hash[String, untyped] fixture, (Integer | String)? status) -> String
743
+ def self.merge_fields: (String type, Hash[String, untyped] example, Hash[Symbol | String, untyped] overrides) -> Hash[String, untyped]
744
+ def self.deep_dup: (untyped value) -> untyped
745
+ def self.deep_freeze: (untyped value) -> untyped
746
+ end
747
+
748
+ def self.response: (Symbol | String operation, ?http_status: (Integer | String)?, **untyped overrides) -> untyped
749
+ def self.attributes: (Symbol | String operation, **untyped overrides) -> Hash[String, untyped]
750
+ PAGINATION_FIELDS: Array[Symbol]
751
+ TYPES: Hash[Symbol, String]
752
+ def self.list_json: (Symbol | String operation, ?(Integer | Array[Hash[Symbol | String, untyped]]) items, ?has_next_page: bool, ?has_previous_page: bool, ?start_cursor: String?, ?end_cursor: String?, ?per_page: Integer?, ?total_count: Integer?) -> Hash[String, untyped]
753
+ def self.pagination_json: (?Hash[String, untyped] example, ?has_next_page: bool, ?has_previous_page: bool, ?start_cursor: String?, ?end_cursor: String?, ?per_page: Integer?, ?total_count: Integer?) -> Hash[String, untyped]
754
+ def self.error_json: (*(String | Array[String]) messages) -> Hash[String, Array[String]]
755
+ def self.http_status: (Symbol | String operation, ?(Integer | String)? http_status) -> Integer
756
+ def self.operation: (Symbol | String name) -> [Symbol, String]
757
+
758
+ module Factories
759
+ OBJECT_CLASSES: Hash[Symbol, untyped]
760
+ TOKEN_EXAMPLE: Hash[String, untyped]
761
+ def object: (Symbol | String factory, **untyped overrides) -> untyped
762
+ def account_info: (?user: Hash[Symbol | String, untyped], **untyped account_overrides) -> Objects::AccountInfo
763
+ def oauth_token: (**untyped overrides) -> OAuth::Token
764
+ def tagged_subscriber: (?tag_names: Array[String], **untyped subscriber_overrides) -> Objects::TaggedSubscriber
765
+ end
766
+ extend Factories
767
+
768
+ module Stubs
769
+ BASE_URL: String
770
+ JSON_HEADERS: Hash[String, String]
771
+ def stub: (Symbol | String operation, ?http_status: (Integer | String)?, **untyped params) -> untyped
772
+ def stub_error: (Symbol | String operation, Integer status, *(String | Array[String]) messages, **untyped path_params) -> untyped
773
+ def stub_rate_limited: (Symbol | String operation, ?retry_after: Integer, **untyped path_params) -> untyped
774
+ def url_for: (Symbol | String operation, **untyped path_params) -> (String | Regexp)
775
+ end
776
+ extend Stubs
777
+
778
+ def self.subscriber: (**untyped overrides) -> Objects::Subscriber
779
+ def self.tag: (**untyped overrides) -> Objects::Tag
780
+ def self.custom_field: (**untyped overrides) -> Objects::CustomField
781
+ def self.sequence: (**untyped overrides) -> Objects::Sequence
782
+ def self.sequence_email: (**untyped overrides) -> Objects::SequenceEmail
783
+ def self.broadcast: (**untyped overrides) -> Objects::Broadcast
784
+ def self.broadcast_stats: (**untyped overrides) -> Objects::BroadcastStats
785
+ def self.post: (**untyped overrides) -> Objects::Post
786
+ def self.snippet: (**untyped overrides) -> Objects::Snippet
787
+ def self.purchase: (**untyped overrides) -> Objects::Purchase
788
+ def self.webhook: (**untyped overrides) -> Objects::Webhook
789
+ def self.webhook_endpoint: (**untyped overrides) -> Objects::WebhookEndpoint
790
+ def self.creator_profile: (**untyped overrides) -> Objects::CreatorProfile
791
+ def self.email_stats: (**untyped overrides) -> Objects::EmailStats
792
+ def self.growth_stats: (**untyped overrides) -> Objects::GrowthStats
793
+ def self.subscriber_stats: (**untyped overrides) -> Objects::SubscriberStats
794
+ def self.account: (**untyped overrides) -> Objects::Account
795
+
796
+ def self.subscriber_json: (**untyped overrides) -> Hash[String, untyped]
797
+ def self.tag_json: (**untyped overrides) -> Hash[String, untyped]
798
+ def self.custom_field_json: (**untyped overrides) -> Hash[String, untyped]
799
+ def self.sequence_json: (**untyped overrides) -> Hash[String, untyped]
800
+ def self.sequence_email_json: (**untyped overrides) -> Hash[String, untyped]
801
+ def self.broadcast_json: (**untyped overrides) -> Hash[String, untyped]
802
+ def self.broadcast_stats_json: (**untyped overrides) -> Hash[String, untyped]
803
+ def self.post_json: (**untyped overrides) -> Hash[String, untyped]
804
+ def self.snippet_json: (**untyped overrides) -> Hash[String, untyped]
805
+ def self.purchase_json: (**untyped overrides) -> Hash[String, untyped]
806
+ def self.webhook_json: (**untyped overrides) -> Hash[String, untyped]
807
+ def self.webhook_endpoint_json: (**untyped overrides) -> Hash[String, untyped]
808
+ def self.creator_profile_json: (**untyped overrides) -> Hash[String, untyped]
809
+ def self.email_stats_json: (**untyped overrides) -> Hash[String, untyped]
810
+ def self.growth_stats_json: (**untyped overrides) -> Hash[String, untyped]
811
+ def self.subscriber_stats_json: (**untyped overrides) -> Hash[String, untyped]
812
+ def self.account_json: (**untyped overrides) -> Hash[String, untyped]
813
+ end
814
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kit-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Lin
@@ -54,6 +54,7 @@ files:
54
54
  - lib/kit/configuration.rb
55
55
  - lib/kit/connection.rb
56
56
  - lib/kit/errors.rb
57
+ - lib/kit/instrumentation.rb
57
58
  - lib/kit/oauth/client.rb
58
59
  - lib/kit/oauth/pkce.rb
59
60
  - lib/kit/oauth/token.rb
@@ -97,6 +98,13 @@ files:
97
98
  - lib/kit/resources/tags.rb
98
99
  - lib/kit/resources/webhook_endpoints.rb
99
100
  - lib/kit/resources/webhooks.rb
101
+ - lib/kit/tag_names.rb
102
+ - lib/kit/testing.rb
103
+ - lib/kit/testing/factories.rb
104
+ - lib/kit/testing/fixtures.json
105
+ - lib/kit/testing/fixtures.rb
106
+ - lib/kit/testing/operations.rb
107
+ - lib/kit/testing/stubs.rb
100
108
  - lib/kit/version.rb
101
109
  - lib/kit/webhooks/delivery.rb
102
110
  - lib/kit/webhooks/events.rb