parallel588-klaviyo 0.11.0 → 0.12.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55977b3cc2ea79d37bf96277a023c3251fe486b9
4
- data.tar.gz: f21b4dc26a73ea486a80cebc0544bd435e47c22a
3
+ metadata.gz: 76ed78477b7ec3a369b9105402afcb2a358d7e6c
4
+ data.tar.gz: c28a9bf6b61d8ae6ba59d53705ede5490d73e7b1
5
5
  SHA512:
6
- metadata.gz: 21c3cffda22da8f7bcde3f517513976271f6670ec2a68d49aac92f2c6ab985b0992ee664a5d9809531929076fbe186c626d8d5d71106af796f26af8a703aadfe
7
- data.tar.gz: 6e8a7971ae47b124cc561640c0af92b1f88014104ea28f582240d3a19dba52b5984e2c3ae03fa15690b1a6097183b9aa8e4995423c35a3076dbc27ac173798c0
6
+ metadata.gz: 935a312c7c982b553a3ea97e9c02c436fbb177fe04d48661e8a50f9e87a32cfd73357e22612c2310de09d55386cf75c951b3db484056fb804456820abb949c80
7
+ data.tar.gz: 2a9515fb81e97c69e4caad16ff545fe7956d0064c14c382d54a875cded8f77481b9c6ff0f18665d2e5d6ed21f6ea65ff93204d174e348e6e5ed3c7216038bcd8
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Klaviyo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/klaviyo`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ https://www.klaviyo.com/docs/http-api
4
+
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,11 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ```ruby
26
+ klaviyo_client = Klaviyo::Client.new(ENV['secret_key'], ENV['public_key'])
27
+ klaviyo_client.people.find(id: user_id)
28
+
29
+ ```
26
30
 
27
31
  ## Development
28
32
 
@@ -33,4 +37,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
37
  ## Contributing
34
38
 
35
39
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/klaviyo.
36
-
data/klaviyo.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'pry', '~> 0.10.3'
30
+ spec.add_development_dependency 'webmock', '~> 2.0', '>= 2.0.3'
30
31
  end
@@ -1,7 +1,7 @@
1
1
  require_relative 'client_dsl'
2
2
  require_relative 'errors'
3
3
  module Klaviyo
4
- API_ENDPOINT = 'https://a.klaviyo.com'
4
+ API_ENDPOINT = 'https://a.klaviyo.com'.freeze
5
5
 
6
6
  class Client
7
7
  extend ClientDSL
@@ -10,6 +10,11 @@ module Klaviyo
10
10
  def initialize(api_key, token)
11
11
  @api_key = api_key
12
12
  @token = token
13
+
14
+ raise Errors::AuthenticationError, 'No API key provided.' unless @api_key
15
+ raise Errors::AuthenticationError, 'No Token provided.' unless @token
16
+
17
+
13
18
  @conn = Faraday.new(
14
19
  url: API_ENDPOINT,
15
20
  ssl: { ca_path: Klaviyo::DEFAULT_CA_BUNDLE_PATH }
@@ -30,7 +35,7 @@ module Klaviyo
30
35
  )
31
36
 
32
37
  {
33
- data: Base64.encode64(JSON.generate(options)).delete("\n")
38
+ data: CGI.escape(Base64.encode64(JSON.generate(options)).delete("\n"))
34
39
  }
35
40
  end
36
41
 
@@ -5,6 +5,7 @@ module Klaviyo
5
5
  class UnprocessableEntity < KlaviyoError; end
6
6
  class InternalServerError < KlaviyoError; end
7
7
  class NotAuthorized < KlaviyoError; end
8
+ class AuthenticationError < KlaviyoError; end
8
9
 
9
10
  class RequestError < Faraday::Response::Middleware
10
11
 
@@ -31,8 +32,3 @@ module Klaviyo
31
32
 
32
33
  end
33
34
  end
34
-
35
- #400 Bad request - Request is missing or has a bad parameter.
36
- #401 Not Authorized - Request is missing or has an invalid API key.
37
- #404 Not Found - The requested resource doesn't exist.
38
- #500 Server errors - Something is wrong on Klaviyo's end.
@@ -1,3 +1,3 @@
1
1
  module Klaviyo
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel588-klaviyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Pechnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -148,6 +148,26 @@ dependencies:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
150
  version: 0.10.3
151
+ - !ruby/object:Gem::Dependency
152
+ name: webmock
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '2.0'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 2.0.3
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '2.0'
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 2.0.3
151
171
  description: Ruby wrapper for the Klaviyo API
152
172
  email:
153
173
  - parallel588@gmail.com