iterable-api-client 0.5.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dec75eb2ce6297758dd87c44acd79435578c29bb16f23402d133c2e24d1f6820
4
- data.tar.gz: 45658c86e6448f1e75948fa150de1bb6133dacefb3d237cf1edc5504ee90591b
3
+ metadata.gz: 9b0390e984dea2a8340da13d59a741e7a6316faa65814f767a4cedafbd76e325
4
+ data.tar.gz: b4b77e7b0767da2e23ad8c3f0a81458897123c30063282092aba897ddc01fd6e
5
5
  SHA512:
6
- metadata.gz: 9dc86fb5a431fddc281eefb86e0ed597b535dad112e03ef53de5027dd723015d8f1ac791d1ba93c1086aef2cd382d619dafaca348147ada3e7d091ed30afc353
7
- data.tar.gz: 8428f4dfd4bec851b1ed30ee7161dfa7f26848f4c210046fb29f8485a002a06c016473366774720f79855179b27f3e8f57793dfcb3203db82956dcef4d50cfd4
6
+ metadata.gz: 4621a4e84456e759f44eee8a49e46ea7903f97ad64e4f4bf7b1d692c9e703d27b5f81204b02f0f810f2c20acee09559bcdcc7baffb7bb22cba329681685c627d
7
+ data.tar.gz: 1b32513fe776e416344624cd51008a35e02acd67cbe944b4c0f11fe22354e29cc1adca5af5122791b5e459d853aea74a65b2ca4dfb65bbf74549454bb945450e
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/tapioca ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
+
13
+ bundle_binstub = File.expand_path('bundle', __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require 'rubygems'
25
+ require 'bundler/setup'
26
+
27
+ load Gem.bin_path('tapioca', 'tapioca')
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -6,6 +8,8 @@ module Iterable
6
8
  # set per request if needed, otherwise the default global
7
9
  # Iterable.config is used
8
10
  class ApiResource
11
+ extend T::Sig
12
+
9
13
  attr_reader :conf
10
14
 
11
15
  ##
@@ -14,6 +18,7 @@ module Iterable
14
18
  # the global [Iterable::Config] via `Iterable.config`
15
19
  #
16
20
  # @return [Iterable::ApiResource]
21
+ sig { params(conf: T.nilable(Iterable::Config)).void }
17
22
  def initialize(conf = nil)
18
23
  @conf = conf || default_config
19
24
  end
@@ -23,6 +28,7 @@ module Iterable
23
28
  # Global Iterable config accessor for class
24
29
  #
25
30
  # @return [Iterable::Config]
31
+ sig { returns(Iterable::Config) }
26
32
  def self.default_config
27
33
  Iterable.config
28
34
  end
@@ -32,6 +38,7 @@ module Iterable
32
38
  # Global Iterable config accessor for instance
33
39
  #
34
40
  # @return [Iterable::Config]
41
+ sig { returns(Iterable::Config) }
35
42
  def default_config
36
43
  self.class.default_config
37
44
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -20,10 +22,10 @@ module Iterable
20
22
  # Initialize CatalogItems with a catalog name and item ID **currently in Beta only**
21
23
  #
22
24
  # @param catalog [String] The name of the catalog to interact with
23
- # @param item_id [String] The string ID of the item to interact with
24
25
  # @param conf [Iterable::Config] A config to optionally pass for requests
25
26
  #
26
27
  # @return [Iterable::Catalog]
28
+ sig { params(catalog: String, conf: T.nilable(Iterable::Config)).void }
27
29
  def initialize(catalog, conf = nil)
28
30
  @catalog = catalog
29
31
  super conf
@@ -33,9 +35,10 @@ module Iterable
33
35
  #
34
36
  # Bulk delete catalog items
35
37
  #
36
- # @param keys [Array] Array of catalog items ids to delete
38
+ # @param item_ids [Array] Array of catalog items ids to delete
37
39
  #
38
40
  # @return [Iterable::Response] A response object
41
+ sig { params(item_ids: Array).returns(Iterable::Response) }
39
42
  def delete(item_ids = [])
40
43
  body = { itemIds: item_ids }
41
44
  Iterable.request(conf, base_path).delete(body)
@@ -45,11 +48,17 @@ module Iterable
45
48
  #
46
49
  # Bulk create catalog items
47
50
  #
48
- # @param documents [Hash] Hash of item ID to item attributes e.g. { '123456': { name: 'foo', state: 'open' } }
51
+ # @param items [Hash] Hash of item ID to item attributes e.g. { '123456': { name: 'foo', state: 'open' } }
49
52
  # @param replace_uploaded_fields_only [Boolean] Whether to replace only the upload fields within each document,
50
53
  # not each entire document. Defaults to false and will replace
51
54
  # existing.
52
55
  # @return [Iterable::Response] A response object
56
+ sig do
57
+ params(
58
+ items: Hash,
59
+ replace_uploaded_fields_only: T::Boolean
60
+ ).returns(Iterable::Response)
61
+ end
53
62
  def create(items = {}, replace_uploaded_fields_only: false)
54
63
  body = {
55
64
  documents: items,
@@ -58,6 +67,7 @@ module Iterable
58
67
  Iterable.request(conf, base_path).post(body)
59
68
  end
60
69
 
70
+ sig { returns(String) }
61
71
  private def base_path
62
72
  "/catalogs/#{@catalog}/items"
63
73
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -17,6 +19,7 @@ module Iterable
17
19
  # Get all campaigns
18
20
  #
19
21
  # @return [Iterable::Response] A response object
22
+ sig { returns(Iterable::Response) }
20
23
  def all
21
24
  Iterable.request(conf, '/campaigns').get
22
25
  end
@@ -31,6 +34,14 @@ module Iterable
31
34
  # @param attrs [Hash] Any other campaign attributes to set
32
35
  #
33
36
  # @return [Iterable::Response] A response object
37
+ sig do
38
+ params(
39
+ name: String,
40
+ template_id: Integer,
41
+ list_ids: Array,
42
+ attrs: Hash
43
+ ).returns(Iterable::Response)
44
+ end
34
45
  def create(name, template_id, list_ids = [], attrs = {})
35
46
  body = attrs.merge(name: name, templateId: template_id, listIds: list_ids)
36
47
  Iterable.request(conf, '/campaigns/create').post(body)
@@ -43,6 +54,7 @@ module Iterable
43
54
  # @param campaign_id [Integer] Root campaign ID to get child recurring campaigns for
44
55
  #
45
56
  # @return [Iterable::Response] A response object
57
+ sig { params(campaign_id: Integer).returns(Iterable::Response) }
46
58
  def recurring(campaign_id)
47
59
  Iterable.request(conf, "/campaigns/recurring/#{campaign_id}/childCampaigns").get
48
60
  end
@@ -51,17 +63,22 @@ module Iterable
51
63
  #
52
64
  # Export metrics in CSV format for one or more campaigns
53
65
  #
54
- # @param name [Array] An array of campaign ids, must have at least one
66
+ # @param campaign_ids [Array] An array of campaign ids, must have at least one
55
67
  # @param start_time [Date|Time] Start of metrics to query for
56
68
  # @param end_time [Date|Time] End of metrics to query for
57
69
  #
58
70
  # @return [Iterable::Response] A response object
71
+ sig do
72
+ params(
73
+ campaign_ids: Array,
74
+ start_time: T.nilable(T.any(Date, Time)),
75
+ end_time: T.nilable(T.any(Date, Time))
76
+ ).returns(Iterable::Response)
77
+ end
59
78
  def metrics(campaign_ids = [], start_time = nil, end_time = nil)
60
79
  params = { campaignId: campaign_ids }
61
- if start_time
62
- params[:startTime] = start_time.to_date.strftime(Iterable::DATE_FORMAT)
63
- params[:endTime] = end_time.to_date.strftime(Iterable::DATE_FORMAT)
64
- end
80
+ params[:startTime] = start_time.to_date.strftime(Iterable::DATE_FORMAT) if start_time
81
+ params[:endTime] = end_time.to_date.strftime(Iterable::DATE_FORMAT) if end_time
65
82
  Iterable.request(conf, '/campaigns/metrics', params).get
66
83
  end
67
84
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -13,6 +15,8 @@ module Iterable
13
15
  # conf = Iterable::Config.new(token: 'new-token')
14
16
  # catalog = Iterable::CatalogFieldMappings.new("catalog-name", config)
15
17
  class CatalogFieldMappings < ApiResource
18
+ extend T::Sig
19
+
16
20
  attr_reader :catalog
17
21
 
18
22
  ##
@@ -23,6 +27,7 @@ module Iterable
23
27
  # @param conf [Iterable::Config] A config to optionally pass for requests
24
28
  #
25
29
  # @return [Iterable::Catalog]
30
+ sig { params(catalog: String, conf: T.any(Iterable::Config, NilClass)).void }
26
31
  def initialize(catalog, conf = nil)
27
32
  @catalog = catalog
28
33
  super conf
@@ -33,6 +38,7 @@ module Iterable
33
38
  # Get field mappings for a catalog
34
39
  #
35
40
  # @return [Iterable::Response] A response object
41
+ sig { returns(Iterable::Response) }
36
42
  def get
37
43
  Iterable.request(conf, base_path).get
38
44
  end
@@ -41,7 +47,8 @@ module Iterable
41
47
  #
42
48
  # Set a catalog's field mappings (data types)
43
49
  #
44
- # @param [Array] Array of field mapping hashes e.g [{"fieldName":"exampleString","fieldType":"string"}]}
50
+ # @param mappings_updates [Array] Array of field mapping hashes
51
+ # e.g [{"fieldName":"exampleString","fieldType":"string"}]}
45
52
  #
46
53
  # @return [Iterable::Response] A response object
47
54
  #
@@ -50,11 +57,13 @@ module Iterable
50
57
  # field_mappings = [{fieldName: 'test-field', fieldType: 'string'}]
51
58
  # catalog = Iterable::CatalogFieldMappings.new "catalog-name"
52
59
  # catalog.update_field_mappings(field_mappings)
60
+ sig { params(mappings_updates: Array).returns(Iterable::Response) }
53
61
  def update(mappings_updates = [])
54
62
  body = { mappingsUpdates: mappings_updates }
55
63
  Iterable.request(conf, base_path).put(body)
56
64
  end
57
65
 
66
+ sig { returns(String) }
58
67
  private def base_path
59
68
  "/catalogs/#{@catalog}/fieldMappings"
60
69
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -24,6 +26,13 @@ module Iterable
24
26
  # @param conf [Iterable::Config] A config to optionally pass for requests
25
27
  #
26
28
  # @return [Iterable::Catalog]
29
+ sig do
30
+ params(
31
+ catalog: String,
32
+ item_id: T.nilable(String),
33
+ conf: T.nilable(Iterable::Config)
34
+ ).void
35
+ end
27
36
  def initialize(catalog, item_id = nil, conf = nil)
28
37
  @catalog = catalog
29
38
  @item_id = item_id
@@ -37,6 +46,7 @@ module Iterable
37
46
  # @param params[Hash] Attribute hash for item query (page, pageSize, orderBy, sortAscending)
38
47
  #
39
48
  # @return [Iterable::Response] A response object
49
+ sig { params(params: Hash).returns(Iterable::Response) }
40
50
  def all(params = {})
41
51
  Iterable.request(conf, base_path, params).get
42
52
  end
@@ -48,6 +58,7 @@ module Iterable
48
58
  # @param item_attrs [Hash] Item attributes to save or replace with
49
59
  #
50
60
  # @return [Iterable::Response] A response object
61
+ sig { params(item_attrs: Hash).returns(Iterable::Response) }
51
62
  def create(item_attrs = {})
52
63
  body = { value: item_attrs }
53
64
  Iterable.request(conf, base_path).put(body)
@@ -61,6 +72,7 @@ module Iterable
61
72
  # @param item_attrs [Hash] Item attributes to save or update with
62
73
  #
63
74
  # @return [Iterable::Response] A response object
75
+ sig { params(item_attrs: Hash).returns(Iterable::Response) }
64
76
  def update(item_attrs = {})
65
77
  body = { update: item_attrs }
66
78
  Iterable.request(conf, base_path).patch(body)
@@ -71,6 +83,7 @@ module Iterable
71
83
  # Get a specific catalog item
72
84
  #
73
85
  # @return [Iterable::Response] A response object
86
+ sig { returns(Iterable::Response) }
74
87
  def get
75
88
  Iterable.request(conf, base_path).get
76
89
  end
@@ -80,10 +93,12 @@ module Iterable
80
93
  # Delete a catalog item
81
94
  #
82
95
  # @return [Iterable::Response] A response object
96
+ sig { returns(Iterable::Response) }
83
97
  def delete
84
98
  Iterable.request(conf, base_path).delete
85
99
  end
86
100
 
101
+ sig { returns(String) }
87
102
  private def base_path
88
103
  path = "/catalogs/#{@catalog}/items"
89
104
  path += "/#{@item_id}" if @item_id
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -23,6 +25,7 @@ module Iterable
23
25
  # @param conf [Iterable::Config] A config to optionally pass for requests
24
26
  #
25
27
  # @return [Iterable::Catalog]
28
+ sig { params(name: String, conf: T.nilable(Iterable::Config)).void }
26
29
  def initialize(name, conf = nil)
27
30
  @name = name
28
31
  super conf
@@ -33,6 +36,7 @@ module Iterable
33
36
  # Create a catalog
34
37
  #
35
38
  # @return [Iterable::Response] A response object
39
+ sig { returns(Iterable::Response) }
36
40
  def create
37
41
  Iterable.request(conf, base_path).post
38
42
  end
@@ -42,6 +46,7 @@ module Iterable
42
46
  # Delete a catalog
43
47
  #
44
48
  # @return [Iterable::Response] A response object
49
+ sig { returns(Iterable::Response) }
45
50
  def delete
46
51
  Iterable.request(conf, base_path).delete
47
52
  end
@@ -51,10 +56,12 @@ module Iterable
51
56
  # Get a list of all catalog names
52
57
  #
53
58
  # @return [Iterable::Response] A response object
59
+ sig { params(params: Hash).returns(Iterable::Response) }
54
60
  def names(params = {})
55
61
  Iterable.request(conf, '/catalogs', params).get
56
62
  end
57
63
 
64
+ sig { returns(String) }
58
65
  private def base_path
59
66
  "/catalogs/#{@name}"
60
67
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -17,6 +19,7 @@ module Iterable
17
19
  # Get all channels
18
20
  #
19
21
  # @return [Iterable::Response] A response object
22
+ sig { returns(Iterable::Response) }
20
23
  def all
21
24
  Iterable.request(conf, '/channels').get
22
25
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -23,6 +25,14 @@ module Iterable
23
25
  # @param attrs [Hash] Track purchase request additional fields
24
26
  #
25
27
  # @return [Iterable::Response] A response object
28
+ sig do
29
+ params(
30
+ total: T.any(String, Float),
31
+ items: T::Array[Hash],
32
+ user: Hash,
33
+ attrs: Hash
34
+ ).returns(Iterable::Response)
35
+ end
26
36
  def track_purchase(total, items = [], user = {}, attrs = {})
27
37
  data = {
28
38
  total: total,
@@ -42,6 +52,12 @@ module Iterable
42
52
  # @param items [Array[Hash]] Array of hashes of commerce items
43
53
  #
44
54
  # @return [Iterable::Response] A response object
55
+ sig do
56
+ params(
57
+ user: Hash,
58
+ items: T::Array[Hash]
59
+ ).returns(Iterable::Response)
60
+ end
45
61
  def update_cart(user = {}, items = [])
46
62
  data = {
47
63
  items: items,
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  # Config provides a class to configre the API calls when interacting with
@@ -6,6 +8,8 @@ module Iterable
6
8
  # @example Creating a config object
7
9
  # Iterable::Config.new token: 'secret-token'
8
10
  class Config
11
+ extend T::Sig
12
+
9
13
  DEFAULT_VERSION = '1.8'.freeze
10
14
  DEFAULT_HOST = 'https://api.iterable.com'.freeze
11
15
  DEFAULT_URI = "#{DEFAULT_HOST}/api".freeze
@@ -20,6 +24,7 @@ module Iterable
20
24
  #
21
25
  # @param token [String] Iterable API token
22
26
  # @return [Iterable::Config]
27
+ sig { params(token: T.nilable(String)).void }
23
28
  def initialize(token: nil)
24
29
  @host = DEFAULT_HOST
25
30
  @port = DEFAULT_PORT
@@ -32,6 +37,7 @@ module Iterable
32
37
  # Creates a [URI] for the API host
33
38
  #
34
39
  # @return [URI] API URI object
40
+ sig { returns(URI) }
35
41
  def uri
36
42
  URI.parse("#{@host || DEFAULT_HOST}:#{@port || DEFAULT_PORT}/api")
37
43
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -12,6 +14,7 @@ module Iterable
12
14
  # conf = Iterable::Config.new(token: 'new-token')
13
15
  # exporter = Iterable::CsvExporter.new(Iterable::Export::EMAIL_SEND_TYPE, nil, nil, nil, config)
14
16
  class CsvExporter < Export
17
+ sig { override.returns(String) }
15
18
  def format
16
19
  'csv'
17
20
  end
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -31,6 +33,15 @@ module Iterable
31
33
  # @param conf [Iterable::Config] A config to optionally pass for requests
32
34
  #
33
35
  # @return [Iterable::Device]
36
+ sig do
37
+ params(
38
+ token: String,
39
+ app: String,
40
+ platform: String,
41
+ data_fields: Hash,
42
+ conf: T.nilable(Iterable::Config)
43
+ ).void
44
+ end
34
45
  def initialize(token, app, platform, data_fields = {}, conf = nil)
35
46
  @token = token
36
47
  @app = app
@@ -47,6 +58,7 @@ module Iterable
47
58
  # @param user_id [String] User ID to associate device with instead of email
48
59
  #
49
60
  # @return [Iterable::Response] A response object
61
+ sig { params(email: String, user_id: T.nilable(String)).returns(Iterable::Response) }
50
62
  def register(email, user_id = nil)
51
63
  attrs = {
52
64
  device: device_data
@@ -56,10 +68,12 @@ module Iterable
56
68
  Iterable.request(conf, base_path).post(attrs)
57
69
  end
58
70
 
71
+ sig { returns(String) }
59
72
  private def base_path
60
73
  '/users/registerDeviceToken'
61
74
  end
62
75
 
76
+ sig { returns(Hash) }
63
77
  private def device_data
64
78
  {
65
79
  token: @token,
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -18,9 +20,16 @@ module Iterable
18
20
  #
19
21
  # @param email [String] Email of user who received the message to view
20
22
  # @param message_id [String|Integer] Message id for message sent
21
- # @param attrs [Hash] Hash of attributes to pass like dataFields with the requst
23
+ # @param attrs [Hash] Hash of attributes to pass like dataFields with the request
22
24
  #
23
25
  # @return [Iterable::Response] A response object
26
+ sig do
27
+ params(
28
+ email: T.nilable(String),
29
+ message_id: T.any(String, Integer),
30
+ attrs: Hash
31
+ ).returns(Iterable::Response)
32
+ end
24
33
  def view(email, message_id, attrs = {})
25
34
  attrs['email'] = email
26
35
  attrs['messageId'] = message_id
@@ -38,6 +47,13 @@ module Iterable
38
47
  # @param attrs [Hash] Hash of attributes to pass like dataFields with the request
39
48
  #
40
49
  # @return [Iterable::Response] A response object
50
+ sig do
51
+ params(
52
+ email: String,
53
+ campaign_id: Integer,
54
+ attrs: Hash
55
+ ).returns(Iterable::Response)
56
+ end
41
57
  def target(email, campaign_id, attrs = {})
42
58
  attrs[:recipientEmail] = email
43
59
  attrs[:campaignId] = campaign_id
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -20,6 +22,12 @@ module Iterable
20
22
  # @param params [Hash] Additional params to use such as locale
21
23
  #
22
24
  # @return [Iterable::Response] A response object
25
+ sig do
26
+ params(
27
+ template_id: T.any(String, Integer),
28
+ params: Hash
29
+ ).returns(Iterable::Response)
30
+ end
23
31
  def get(template_id, params = {})
24
32
  params['templateId'] = template_id
25
33
  Iterable.request(conf, '/templates/email/get', params).get
@@ -33,6 +41,12 @@ module Iterable
33
41
  # @param attrs [Hash] Update attributes
34
42
  #
35
43
  # @return [Iterable::Response] A response object
44
+ sig do
45
+ params(
46
+ template_id: T.any(String, Integer),
47
+ attrs: Hash
48
+ ).returns(Iterable::Response)
49
+ end
36
50
  def update(template_id, attrs = {})
37
51
  attrs['templateId'] = template_id
38
52
  Iterable.request(conf, '/templates/email/update').post(attrs)
@@ -46,6 +60,12 @@ module Iterable
46
60
  # @param attrs [Hash] Update attributes
47
61
  #
48
62
  # @return [Iterable::Response] A response object
63
+ sig do
64
+ params(
65
+ client_template_id: String,
66
+ attrs: Hash
67
+ ).returns(Iterable::Response)
68
+ end
49
69
  def upsert(client_template_id, attrs = {})
50
70
  attrs['clientTemplateId'] = client_template_id
51
71
  Iterable.request(conf, '/templates/email/upsert').post(attrs)
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -20,6 +22,12 @@ module Iterable
20
22
  # @param limit [Integer] Limit of events to return, max 200 default 30
21
23
  #
22
24
  # @return [Iterable::Response] A response object
25
+ sig do
26
+ params(
27
+ email: String,
28
+ limit: Integer
29
+ ).returns(Iterable::Response)
30
+ end
23
31
  def for_email(email, limit = 30)
24
32
  Iterable.request(conf, "/events/#{email}", limit: limit).get
25
33
  end
@@ -33,6 +41,13 @@ module Iterable
33
41
  # @param attrs [Hash] Event values and fields to include
34
42
  #
35
43
  # @return [Iterable::Response] A response object
44
+ sig do
45
+ params(
46
+ name: T.nilable(String),
47
+ email: T.nilable(String),
48
+ attrs: Hash
49
+ ).returns(Iterable::Response)
50
+ end
36
51
  def track(name, email = nil, attrs = {})
37
52
  attrs[:eventName] = name
38
53
  attrs[:email] = email
@@ -48,6 +63,7 @@ module Iterable
48
63
  # @return [Iterable::Response] A response object
49
64
  #
50
65
  # @note Event fields can be eventName [String], email [String], dataFields [Hash], or userId [String]
66
+ sig { params(events: T::Array[Hash]).returns(Iterable::Response) }
51
67
  def track_bulk(events = [])
52
68
  Iterable.request(conf, '/events/trackBulk').post(events: events)
53
69
  end
@@ -62,6 +78,14 @@ module Iterable
62
78
  # @param attrs [Hash] Event values and fields to include
63
79
  #
64
80
  # @return [Iterable::Response] A response object
81
+ sig do
82
+ params(
83
+ campaign_id: T.any(String, Integer),
84
+ message_id: T.any(String, Integer),
85
+ email: T.nilable(String),
86
+ attrs: Hash
87
+ ).returns(Iterable::Response)
88
+ end
65
89
  def track_push_open(campaign_id, message_id, email, attrs = {})
66
90
  attrs[:campaignId] = campaign_id
67
91
  attrs[:messageId] = message_id
@@ -1,3 +1,5 @@
1
+ # typed: true
2
+
1
3
  module Iterable
2
4
  ##
3
5
  #
@@ -22,6 +24,12 @@ module Iterable
22
24
  # @param conf [Iterable::Config] A config to optionally pass for requests
23
25
  #
24
26
  # @return [Iterable::Experiments]
27
+ sig do
28
+ params(
29
+ experiment_ids: T::Array[Integer],
30
+ conf: T.nilable(Iterable::Config)
31
+ ).void
32
+ end
25
33
  def initialize(experiment_ids = [], conf = nil)
26
34
  @experiment_ids = experiment_ids
27
35
  super conf
@@ -31,20 +39,25 @@ module Iterable
31
39
  #
32
40
  # Get metrics for experiments
33
41
  #
34
- # @params campaign_ids [Array] Array of campaignIds to optionally query for
42
+ # @param campaign_ids [Array] Array of campaignIds to optionally query for
35
43
  # @param start_time [Date|Time] Start of metrics to query for
36
44
  # @param end_time [Date|Time] End of metrics to query for
37
45
  #
38
46
  # @return [Iterable::Response] A response object
47
+ sig do
48
+ params(
49
+ campaign_ids: Array,
50
+ start_time: T.any(Date, Time, NilClass),
51
+ end_time: T.any(Date, Time, NilClass)
52
+ ).returns(Iterable::Response)
53
+ end
39
54
  def metrics(campaign_ids = [], start_time = nil, end_time = nil)
40
55
  params = {
41
56
  experimentId: @experiment_ids,
42
57
  campaignId: campaign_ids
43
58
  }
44
- if start_time
45
- params[:startTime] = start_time.to_date.strftime(Iterable::DATE_FORMAT)
46
- params[:endTime] = end_time.to_date.strftime(Iterable::DATE_FORMAT)
47
- end
59
+ params[:startTime] = start_time.to_date.strftime(Iterable::DATE_FORMAT) if start_time
60
+ params[:endTime] = end_time.to_date.strftime(Iterable::DATE_FORMAT) if end_time
48
61
  Iterable.request(conf, '/experiments/metrics', params).get
49
62
  end
50
63
  end