mailerlite 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 429068032003d8d580e7558e2cdb4ebe03837156
4
- data.tar.gz: 6a079e90259500321c692d80c6ae269fbcc9c29f
3
+ metadata.gz: 8778460cc49d8f082a725d64b698686907432a79
4
+ data.tar.gz: 7172a78894facf2a778c839158c3f0521419ec2a
5
5
  SHA512:
6
- metadata.gz: f48c09315918f8061f0d8669f0873de0491f0cacaff59fa1615fabc299ace35b1729680ad853ee8922e31069361d758698b479d9dcbb34d41a19686dcf6782a0
7
- data.tar.gz: 58b50f488ae6107d6808d8c237f3ff73405b3a0cf626c93ab6ae13bacdb3757462492e1f297be09afaf8066592c18cade543a2baac4d187e4b4a9d363a8a873e
6
+ metadata.gz: dff75234d4a7540eeb19c19e8646f1a106c10a3818ff4471fa030417c196672e388f0d270749616649b1a9075ee2dbaa7bfd1d39177584b56f150048a8e7dd4d
7
+ data.tar.gz: c4cb1b149695aadbde493de0dd305edc51e796ba54e5b54f6e6306b92295049c92ee28285eed72b22d9db97e23675dec08042dfd3228acc178ed59c5dc83ccda
data/README.md CHANGED
@@ -47,10 +47,15 @@ implementations:
47
47
  * Ruby 2.2.0
48
48
  * Ruby 2.3.0
49
49
 
50
+ ## Copyright
51
+ Copyright (c) 2016 Justas Palumickas. See [LICENSE][license] for details.
52
+
50
53
  [rubygems]: https://rubygems.org/gems/mailerlite
51
54
  [travis]: http://travis-ci.org/jpalumickas/mailerlite-ruby
52
55
  [gemnasium]: https://gemnasium.com/jpalumickas/mailerlite-ruby
53
56
  [coveralls]: https://coveralls.io/r/jpalumickas/mailerlite-ruby
54
57
  [codeclimate]: https://codeclimate.com/github/jpalumickas/mailerlite-ruby
55
58
 
59
+ [license]: https://raw.githubusercontent.com/jpalumickas/mailerlite-ruby/master/LICENSE
60
+
56
61
  [mailerlite]: https://www.mailerlite.com
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "mailerlite"
3
+ require 'bundler/setup'
4
+ require 'mailerlite'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "mailerlite"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -0,0 +1,38 @@
1
+ # Authentication Example
2
+
3
+ When you sign up for an account, you are given an **API key**. You authenticate to
4
+ the [MailerLite][mailerlite] API by providing your API key in the request.
5
+ You can find your API key in page: Integrations » Developer API.
6
+
7
+ ## Using variable
8
+
9
+ ```ruby
10
+ client = MailerLite::Client.new(api_key: 'my-secret-api-key')
11
+ ```
12
+
13
+ Example:
14
+
15
+ ```ruby
16
+ client.campaigns
17
+ ```
18
+
19
+ ## Using global class config
20
+
21
+ Or create file under `config/initializers/mailerlite.rb`
22
+
23
+ ```ruby
24
+ MailerLite.configure do |config|
25
+ config.api_key = 'my-secret-api-key'
26
+ end
27
+ ```
28
+
29
+ When you configured in file, you can request methods on `MailerLite` class
30
+ directly.
31
+
32
+ Example:
33
+
34
+ ```ruby
35
+ MailerLite.campaigns
36
+ ```
37
+
38
+ [mailerlite]: https://www.mailerlite.com
@@ -0,0 +1,62 @@
1
+ # Campaigns
2
+
3
+ ## Get all campaigns
4
+
5
+ Returns all campaigns you have in your account.
6
+ Also basic summary for each campaign including the ID.
7
+
8
+ #### Example:
9
+
10
+ ```ruby
11
+ client.campaigns
12
+ ```
13
+
14
+ You can specify **limit** and **page** options:
15
+
16
+ ```ruby
17
+ client.campaings(limit: 200, page: 2)
18
+ ```
19
+
20
+ ## Campaign details
21
+
22
+ Retrieve stats about selected campaign with specified ID.
23
+
24
+ #### Example:
25
+
26
+ ```ruby
27
+ campaign_id = 123
28
+ client.campaign(campaign_id)
29
+ ```
30
+
31
+ ## Campaign recipients
32
+
33
+ Retrieves a paged result representing all the subscribers that a given campaign was sent to.
34
+
35
+ #### Example:
36
+
37
+ ```ruby
38
+ client.campaign_recipients(123)
39
+ ```
40
+
41
+ You can specify **limit** and **page** options:
42
+
43
+ ```ruby
44
+ client.campaing_recipients(123, limit: 200, page: 2)
45
+ ```
46
+
47
+
48
+ ## Campaign opens
49
+
50
+ Retrieves a paged result representing all the subscribers that opened a given campaign.
51
+
52
+ #### Example:
53
+
54
+ ```ruby
55
+ client.campaign_opens(123)
56
+ ```
57
+
58
+ You can specify **limit** and **page** options:
59
+
60
+ ```ruby
61
+ client.campaing_opens(123, limit: 200, page: 2)
62
+ ```
data/lib/mailerlite.rb CHANGED
@@ -4,6 +4,7 @@ require 'mailerlite/version'
4
4
  require 'mailerlite/error'
5
5
  require 'mailerlite/client'
6
6
 
7
+ # Main module for gem.
7
8
  module MailerLite
8
9
  class << self
9
10
  def client
@@ -3,11 +3,14 @@ require 'mailerlite/configuration'
3
3
 
4
4
  require 'mailerlite/clients/campaigns'
5
5
  require 'mailerlite/clients/lists'
6
+ require 'mailerlite/clients/subscribers'
6
7
 
7
8
  module MailerLite
9
+ # Wrapper class for all actions.
8
10
  class Client
9
11
  include MailerLite::Clients::Campaigns
10
12
  include MailerLite::Clients::Lists
13
+ include MailerLite::Clients::Subscribers
11
14
 
12
15
  def initialize(options = {})
13
16
  config.api_key = options[:api_key] if options[:api_key]
@@ -16,6 +19,7 @@ module MailerLite
16
19
  def config
17
20
  @config ||= Configuration.new
18
21
  end
22
+ alias configuration config
19
23
 
20
24
  def configure
21
25
  yield(config) if block_given?
@@ -0,0 +1,33 @@
1
+ module MailerLite
2
+ module Clients
3
+ # Get information about MailerLite Subscribers.
4
+ #
5
+ # You can official documentation at
6
+ # https://docs.mailerlite.com/pages/subscribers
7
+ module Subscribers
8
+ def create_subscriber(list_id, email, options = {})
9
+ options[:email] = email
10
+
11
+ connection.post("subscribers/#{list_id}/", options)
12
+ end
13
+
14
+ def create_subscribers(list_id, options = {})
15
+ connection.post("subscribers/#{list_id}/import/", options)
16
+ end
17
+
18
+ def subscriber(email, options = {})
19
+ options[:email] = email
20
+
21
+ connection.get('subscribers/', options)
22
+ end
23
+
24
+ def delete_subscriber(list_id, email)
25
+ connection.delete("subscribers/#{list_id}/", email: email)
26
+ end
27
+
28
+ def unsubscribe_subscriber(email)
29
+ connection.post('subscribers/unsubscribe/', email: email)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,5 @@
1
- require 'faraday_middleware'
2
-
3
1
  module MailerLite
2
+ # A class responsible for all configurations.
4
3
  class Configuration
5
4
  # Default API endpoint
6
5
  API_ENDPOINT = 'https://app.mailerlite.com/api/v1'.freeze
@@ -1,10 +1,12 @@
1
1
  require 'faraday'
2
+ require 'faraday_middleware'
2
3
  require 'json'
3
4
 
4
5
  require 'mailerlite/middleware/raise_error'
5
6
  require 'mailerlite/middleware/underscore_keys'
6
7
 
7
8
  module MailerLite
9
+ # A class responsible for connecting to MailerLite API and making requests.
8
10
  class Connection
9
11
  attr_reader :client
10
12
 
@@ -1,9 +1,10 @@
1
+ # Custom String extensions
1
2
  class String
2
3
  def underscore
3
- self.gsub(/::/, '/').
4
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
- tr("-", "_").
7
- downcase
4
+ gsub(/::/, '/')
5
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
6
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
7
+ .tr('-', '_')
8
+ .downcase
8
9
  end
9
10
  end
@@ -1,4 +1,5 @@
1
1
  module MailerLite
2
+ # Base MailerLite error.
2
3
  class Error < StandardError
3
4
  # Returns the appropriate MailerLite::Error sublcass based
4
5
  # on status and response message.
@@ -1,3 +1,3 @@
1
1
  module MailerLite
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailerlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justas Palumickas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-17 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -111,10 +111,13 @@ files:
111
111
  - Rakefile
112
112
  - bin/console
113
113
  - bin/setup
114
+ - examples/authentication.md
115
+ - examples/campaigns.md
114
116
  - lib/mailerlite.rb
115
117
  - lib/mailerlite/client.rb
116
118
  - lib/mailerlite/clients/campaigns.rb
117
119
  - lib/mailerlite/clients/lists.rb
120
+ - lib/mailerlite/clients/subscribers.rb
118
121
  - lib/mailerlite/configuration.rb
119
122
  - lib/mailerlite/connection.rb
120
123
  - lib/mailerlite/core_ext/string.rb