klaviyo 2.0.1 → 2.0.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
- SHA1:
3
- metadata.gz: a6eaa11bdc826d37a755546d9cb771a469ff9039
4
- data.tar.gz: 9f599d1c47bc281311a8adeb5f0c90e8467e4b65
2
+ SHA256:
3
+ metadata.gz: 2b799e59210fdba2f42e88c903a4194f826590309e50650cbf360016bb0fd14e
4
+ data.tar.gz: df417c927034075c4894d2c186bc4f5a50ca2e26ed3e825a659adbd73f6524e6
5
5
  SHA512:
6
- metadata.gz: 9a9ddabcb4a51a640a3f6b265d329a77934a5146803a4e4c67482fe4fbb7589e8dc722c193c55a7ae547ef917da6a61ad44e666442f7107f0963affdb8af7166
7
- data.tar.gz: a04c3224f53c41f732e99f423b0e0e895772b3edd87b2824b179aec24f14c258f12f541631d035550fab32241f43558d04dd92b159fb9145e83d76737ee36d5b
6
+ metadata.gz: 1ef1843515b936f2fd60b91dbd3d3cdaea780b56b49379134c04211c4609ad12ad1a296225fe576418bd93f0a437d88ec212c8b3f02fc6aa5289b5e39db7d5b1
7
+ data.tar.gz: e77f951331a55720f0f8f38a01d7ce51707f4cf316cd3eeeabc64739090ef1a41e5387e84b831bf703f3e19004bf35ec91d3b5e3e624bc94cec23fb4b1b6646f
@@ -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.1'
6
- s.date = '2020-11-23'
5
+ s.version = '2.0.2'
6
+ s.date = '2020-12-28'
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']
@@ -8,16 +8,18 @@ module Klaviyo
8
8
  def self.identify(kwargs = {})
9
9
  defaults = {:id => nil,
10
10
  :email => nil,
11
+ :phone_number => nil,
11
12
  :properties => {}
12
13
  }
13
14
  kwargs = defaults.merge(kwargs)
14
15
 
15
- if !check_email_or_id_exists(kwargs)
16
+ unless check_required_args(kwargs)
16
17
  return
17
18
  end
18
19
 
19
20
  properties = kwargs[:properties]
20
21
  properties[:email] = kwargs[:email] unless kwargs[:email].to_s.empty?
22
+ properties[:$phone_number] = kwargs[:phone_number] unless kwargs[:phone_number].to_s.empty?
21
23
  properties[:id] = kwargs[:id] unless kwargs[:id].to_s.empty?
22
24
 
23
25
  params = {
@@ -33,6 +35,7 @@ module Klaviyo
33
35
  # @param event [String] the event to track
34
36
  # @kwarg :id [String] the customer or profile id
35
37
  # @kwarg :email [String] the customer or profile email
38
+ # @kwarg :phone_number [String] the customer or profile phone number
36
39
  # @kwarg :properties [Hash] properties of the event
37
40
  # @kwargs :customer_properties [Hash] properties of the customer or profile
38
41
  # @kwargs :time [Integer] timestamp of the event
@@ -40,6 +43,7 @@ module Klaviyo
40
43
  defaults = {
41
44
  :id => nil,
42
45
  :email => nil,
46
+ :phone_number => nil,
43
47
  :properties => {},
44
48
  :customer_properties => {},
45
49
  :time => nil
@@ -47,12 +51,13 @@ module Klaviyo
47
51
 
48
52
  kwargs = defaults.merge(kwargs)
49
53
 
50
- if !check_email_or_id_exists(kwargs)
54
+ unless check_required_args(kwargs)
51
55
  return
52
56
  end
53
57
 
54
58
  customer_properties = kwargs[:customer_properties]
55
59
  customer_properties[:email] = kwargs[:email] unless kwargs[:email].to_s.empty?
60
+ customer_properties[:$phone_number] = kwargs[:phone_number] unless kwargs[:phone_number].to_s.empty?
56
61
  customer_properties[:id] = kwargs[:id] unless kwargs[:id].to_s.empty?
57
62
 
58
63
  params = {
@@ -63,9 +63,9 @@ module Klaviyo
63
63
  "data=#{Base64.encode64(JSON.generate(params)).gsub(/\n/,'')}"
64
64
  end
65
65
 
66
- def self.check_email_or_id_exists(kwargs)
67
- if kwargs[:email].to_s.empty? and kwargs[:id].to_s.empty?
68
- raise Klaviyo::KlaviyoError.new(NO_ID_OR_EMAIL_ERROR)
66
+ def self.check_required_args(kwargs)
67
+ if kwargs[:email].to_s.empty? and kwargs[:phone_number].to_s.empty? and kwargs[:id].to_s.empty?
68
+ raise Klaviyo::KlaviyoError.new(REQUIRED_ARG_ERROR)
69
69
  else
70
70
  return true
71
71
  end
@@ -19,5 +19,5 @@ module Klaviyo
19
19
 
20
20
  NO_PRIVATE_API_KEY_ERROR = 'Please provide your Private API key for this request'
21
21
  NO_PUBLIC_API_KEY_ERROR = 'Please provide your Public API key for this request'
22
- NO_ID_OR_EMAIL_ERROR = 'You must identify a user by email or ID'
22
+ REQUIRED_ARG_ERROR = 'You must identify a user by email, ID or phone_number'
23
23
  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.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaviyo Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-23 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -84,7 +84,7 @@ files:
84
84
  homepage: https://www.klaviyo.com/
85
85
  licenses: []
86
86
  metadata: {}
87
- post_install_message:
87
+ post_install_message:
88
88
  rdoc_options: []
89
89
  require_paths:
90
90
  - lib
@@ -99,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.5.1
104
- signing_key:
102
+ rubygems_version: 3.0.8
103
+ signing_key:
105
104
  specification_version: 4
106
105
  summary: You heard us, a Ruby wrapper for the Klaviyo API
107
106
  test_files: []