klaviyo 2.0.9 → 2.0.7

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: f20097f9b9538503cc8f541dd7e6d71c6c70904e51fdd59f636670f56d0b53c5
4
- data.tar.gz: 98032c0e8a4ac60b16501495b71d35ce09bd28bd62fce4c49392448929555ffa
3
+ metadata.gz: fd15569462efd51dde6435c9a861cff6503687426b7df8d6b31c626f5a8cd219
4
+ data.tar.gz: 01517c8f0f9de3c2d94bfa9bb470f7031f4b92ac5e1d3c96eda17d4041459b32
5
5
  SHA512:
6
- metadata.gz: e4f99398385906828f37a4e1f25f05ca76493a905d526177da2cc189301fba84adc76551711213c85003337b0278d0cade9c8ba52e0c0726176465fd2c8132cd
7
- data.tar.gz: e109724a853cbf44a3546298fdfc04037a9cfb748b72a3edd96fab1475e209a3ea67c697ce940ff54d6aac57120f37aa853076398c016995b1b4b11f70279694
6
+ metadata.gz: 033abf3a29a87bdab5ab380419c3b9a37c6430c3b93a68dd87abcd88c2f69a2922f7127b525eda6282d696eaebcb50f706a551cfadf6d747ef3efbcf62ad9b23
7
+ data.tar.gz: 1cc3ddfa7eeb7fc0b09e8ce7192077c56d9d7323f4ed52cddccf16ce528f046582db3182189a9e6fdfd0d991eeb72bd94f2aa336dcb6ea66fc2fd00fec4119d6
data/klaviyo.gemspec CHANGED
@@ -2,8 +2,8 @@ files = ['klaviyo.gemspec', '{lib}/**/**/*'].map {|f| Dir[f]}.flatten
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'klaviyo'
5
- s.version = '2.0.9'
6
- s.date = '2021-07-30'
5
+ s.version = '2.0.7'
6
+ s.date = '2021-04-20'
7
7
  s.summary = 'You heard us, a Ruby wrapper for the Klaviyo API'
8
8
  s.description = 'Ruby wrapper for the Klaviyo API'
9
9
  s.authors = ['Klaviyo Team']
@@ -11,9 +11,9 @@ module Klaviyo
11
11
  unless ['email', 'phone_number', 'person_id'].include? id_type
12
12
  raise Klaviyo::KlaviyoError.new(INVALID_ID_TYPE_ERROR)
13
13
  end
14
- data = Hash[id_type.to_sym, identifier]
14
+ identifier = { id_type => identifier }
15
15
  path = "#{DATA_PRIVACY}/#{DELETION_REQUEST}"
16
- v2_request(HTTP_POST, path, **data)
16
+ v2_request(HTTP_POST, path, **identifier)
17
17
  end
18
18
  end
19
19
  end
@@ -4,15 +4,12 @@ module Klaviyo
4
4
  #
5
5
  # @kwarg :id [String] the customer or profile id
6
6
  # @kwarg :email [String] the customer or profile email
7
- # @kwarg :phone_number [String] the customer or profile phone number
8
7
  # @kwarg :properties [Hash] properties of the profile to add or update
9
- # @kwargs :method [String] the HTTP method to use for the request. Accepts 'get' or 'post'. Defaults to 'get'.
10
8
  def self.identify(kwargs = {})
11
9
  defaults = {:id => nil,
12
10
  :email => nil,
13
11
  :phone_number => nil,
14
- :properties => {},
15
- :method => HTTP_GET
12
+ :properties => {}
16
13
  }
17
14
  kwargs = defaults.merge(kwargs)
18
15
 
@@ -30,7 +27,7 @@ module Klaviyo
30
27
  :properties => properties
31
28
  }
32
29
 
33
- public_request(kwargs[:method], 'identify', **params)
30
+ public_request(HTTP_GET, 'identify', **params)
34
31
  end
35
32
 
36
33
  # Used for tracking events and customer behaviors
@@ -42,7 +39,6 @@ module Klaviyo
42
39
  # @kwarg :properties [Hash] properties of the event
43
40
  # @kwargs :customer_properties [Hash] properties of the customer or profile
44
41
  # @kwargs :time [Integer] timestamp of the event
45
- # @kwargs :method [String] the HTTP method to use for the request. Accepts 'get' or 'post'. Defaults to 'get'.
46
42
  def self.track(event, kwargs = {})
47
43
  defaults = {
48
44
  :id => nil,
@@ -50,8 +46,7 @@ module Klaviyo
50
46
  :phone_number => nil,
51
47
  :properties => {},
52
48
  :customer_properties => {},
53
- :time => nil,
54
- :method => HTTP_GET
49
+ :time => nil
55
50
  }
56
51
 
57
52
  kwargs = defaults.merge(kwargs)
@@ -73,7 +68,7 @@ module Klaviyo
73
68
  }
74
69
  params[:time] = kwargs[:time] if kwargs[:time]
75
70
 
76
- public_request(kwargs[:method], 'track', **params)
71
+ public_request(HTTP_GET, 'track', **params)
77
72
  end
78
73
 
79
74
  def self.track_once(event, kwargs = {})
@@ -40,21 +40,10 @@ module Klaviyo
40
40
  end
41
41
 
42
42
  def self.public_request(method, path, **kwargs)
43
- check_public_api_key_is_valid()
44
- if method == HTTP_GET
45
- params = build_params(kwargs)
46
- url = "#{BASE_API_URL}/#{path}?#{params}"
47
- res = Faraday.get(url).body
48
- elsif method == HTTP_POST
49
- url = URI("#{BASE_API_URL}/#{path}")
50
- response = Faraday.post(url) do |req|
51
- req.headers['Content-Type'] = CONTENT_URL_FORM
52
- req.headers['Accept'] = 'text/html'
53
- req.body = {data: "#{kwargs.to_json}"}
54
- end
55
- else
56
- raise KlaviyoError.new(INVALID_HTTP_METHOD)
57
- end
43
+ check_public_api_key_exists()
44
+ params = build_params(kwargs)
45
+ url = "#{BASE_API_URL}/#{path}?#{params}"
46
+ res = Faraday.get(url).body
58
47
  end
59
48
 
60
49
  def self.v1_request(method, path, content_type: CONTENT_JSON, **kwargs)
@@ -107,16 +96,10 @@ module Klaviyo
107
96
  end
108
97
  end
109
98
 
110
- def self.check_public_api_key_is_valid()
99
+ def self.check_public_api_key_exists()
111
100
  if !Klaviyo.public_api_key
112
101
  raise KlaviyoError.new(NO_PUBLIC_API_KEY_ERROR)
113
102
  end
114
- if ( Klaviyo.public_api_key =~ /pk_\w{34}$/ ) == 0
115
- raise KlaviyoError.new(PRIVATE_KEY_AS_PUBLIC)
116
- end
117
- if ( Klaviyo.public_api_key =~ /\w{6}$/ ) != 0
118
- raise KlaviyoError.new(INCORRECT_PUBLIC_API_KEY_LENGTH)
119
- end
120
103
  end
121
104
 
122
105
  def self.encode_params(kwargs)
@@ -24,7 +24,4 @@ module Klaviyo
24
24
  NO_PUBLIC_API_KEY_ERROR = 'Please provide your Public API key for this request'
25
25
  REQUIRED_ARG_ERROR = 'You must identify a user by email, ID or phone_number'
26
26
  INVALID_ID_TYPE_ERROR = 'Invalid id_type provided, must be one of: email, phone_number, person_id'
27
- PRIVATE_KEY_AS_PUBLIC = 'Private API key added in place of Public API key'
28
- INCORRECT_PUBLIC_API_KEY_LENGTH = 'Public API Key must be 6 characters'
29
- INVALID_HTTP_METHOD = 'Invalid HTTP method present, please use "get" or "post"'
30
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klaviyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaviyo Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-30 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json