apsis-on-steroids 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -10
- data/VERSION +1 -1
- data/apsis-on-steroids.gemspec +3 -3
- data/include/sending.rb +36 -8
- data/spec/apsis-on-steroids_spec.rb +7 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb74fb8c4341b361e40ced00d058ad1236ee6253
|
4
|
+
data.tar.gz: ae0d1cba397c2a9cf5d5a845fc12deff7eea36e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27467b1844923491160b11ef6ecbdf9dc032d7a9e0f6b2f0bb3ca3feb75a94cdaa8c3069c44b9007d7fe3732c06cae156308d77657389b847a478e7660a8d168
|
7
|
+
data.tar.gz: 1a4aa0a9a8a38ba5a67c786f8fc8f20125263428ac09e2adc894aab7cd57293ec53104d7aab9983beb9b9819ad6d2abbd98a58f5904042facda9b037178e76f2
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Library that implements the Apsis API in Ruby in regards to administrating subsc
|
|
9
9
|
### Connecting
|
10
10
|
```ruby
|
11
11
|
aos = ApsisOnSteroids.new(
|
12
|
-
:
|
12
|
+
api_key: "[your api key]"
|
13
13
|
)
|
14
14
|
```
|
15
15
|
|
@@ -21,10 +21,10 @@ aos.mailing_lists
|
|
21
21
|
### Create a mailing list
|
22
22
|
```ruby
|
23
23
|
aos.create_mailing_list(
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
24
|
+
Name: "my_awesome_list",
|
25
|
+
FromName: "Kasper Johansen",
|
26
|
+
FromEmail: "kj@naoshi-dev.com",
|
27
|
+
CharacterSet: "utf-8"
|
28
28
|
)
|
29
29
|
```
|
30
30
|
|
@@ -48,11 +48,11 @@ sub = mlist.subscriber_by_email("some@email.com")
|
|
48
48
|
mlist.create_subscribers(
|
49
49
|
[
|
50
50
|
{
|
51
|
-
:
|
52
|
-
:
|
51
|
+
Email: "some@email.com",
|
52
|
+
Name: "Some Name"
|
53
53
|
},{
|
54
|
-
:
|
55
|
-
:
|
54
|
+
Email: "some_other@email.com",
|
55
|
+
Name: "Some Name"
|
56
56
|
}
|
57
57
|
]
|
58
58
|
)
|
@@ -65,7 +65,7 @@ puts "Details: #{sub.details}"
|
|
65
65
|
|
66
66
|
### Update subscribers.
|
67
67
|
```ruby
|
68
|
-
sub.update(:
|
68
|
+
sub.update(Email: "some_third@email.com")
|
69
69
|
```
|
70
70
|
|
71
71
|
### Remove subscriber from a mailing list.
|
@@ -97,6 +97,7 @@ sendings = apsis.sendings_by_date_interval(@date_from, @date_to).to_a
|
|
97
97
|
```
|
98
98
|
|
99
99
|
### Get data from sendings
|
100
|
+
```ruby
|
100
101
|
sendings.opens(count: true) #=> 5
|
101
102
|
sendings.bounces(count: true) #=> 1
|
102
103
|
sendings.clicks(count: true) #=> 3
|
@@ -105,6 +106,7 @@ sendings.opt_outs(count: true) #=> 1
|
|
105
106
|
sendings.clicks.each do |click|
|
106
107
|
puts "ClickData: #{click.data_hash}"
|
107
108
|
end
|
109
|
+
```
|
108
110
|
|
109
111
|
## Contributing to apsis-on-steroids
|
110
112
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/apsis-on-steroids.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: apsis-on-steroids 0.0.
|
5
|
+
# stub: apsis-on-steroids 0.0.10 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "apsis-on-steroids"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.10"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["kaspernj"]
|
14
|
-
s.date = "2014-08-
|
14
|
+
s.date = "2014-08-13"
|
15
15
|
s.description = "A Ruby API for the Apsis mail service. "
|
16
16
|
s.email = "k@spernj.org"
|
17
17
|
s.extra_rdoc_files = [
|
data/include/sending.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
class ApsisOnSteroids::Sending < ApsisOnSteroids::SubBase
|
2
2
|
def clicks args = {}
|
3
|
-
list_for("v1/clicks/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "Click", args)
|
3
|
+
list_for("v1/clicks/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "v1/sendqueues/%{send_queue_id}/clicks", "Click", args)
|
4
4
|
end
|
5
5
|
|
6
6
|
def opens args = {}
|
7
|
-
list_for("v1/opens/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "Open", args)
|
7
|
+
list_for("v1/opens/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "v1/sendqueues/%{send_queue_id}/opens", "Open", args)
|
8
8
|
end
|
9
9
|
|
10
10
|
def bounces args = {}
|
11
|
-
list_for("v1/bounces/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "Bounce", args)
|
11
|
+
list_for("v1/bounces/sendqueues/%{send_queue_id}/page/%{page}/size/%{size}", "v1/sendqueues/%{send_queue_id}/bounces", "Bounce", args)
|
12
12
|
end
|
13
13
|
|
14
14
|
def opt_outs args = {}
|
15
|
-
list_for("v1/optouts/sendqueues/%{send_queue_id}/%{page}/%{size}", "OptOut", args)
|
15
|
+
list_for("v1/optouts/sendqueues/%{send_queue_id}/%{page}/%{size}", "v1/sendqueues/%{send_queue_id}/optouts", "OptOut", args)
|
16
16
|
end
|
17
17
|
|
18
18
|
def mailing_lists
|
@@ -26,22 +26,50 @@ class ApsisOnSteroids::Sending < ApsisOnSteroids::SubBase
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def
|
29
|
+
def list_for_with_dates resource_url, resource_name, args
|
30
|
+
resource_url = resource_url.gsub("%{send_queue_id}", data(:send_queue_id).to_s)
|
31
|
+
|
32
|
+
ub = aos.new_url_builder
|
33
|
+
ub.path = resource_url
|
34
|
+
ub.params["dateFrom"] = args[:date_from].strftime(ApsisOnSteroids::STRFTIME_FORMAT) if args[:date_from]
|
35
|
+
ub.params["dateTo"] = args[:date_to].strftime(ApsisOnSteroids::STRFTIME_FORMAT) if args[:date_to]
|
36
|
+
|
37
|
+
resource_url = ub.build_path_and_params
|
38
|
+
|
39
|
+
queued_res = aos.req_json(resource_url)
|
40
|
+
results = aos.read_queued_response(queued_res["Result"]["PollURL"])
|
41
|
+
|
42
|
+
return results.length if args[:count]
|
43
|
+
|
44
|
+
Enumerator.new do |yielder|
|
45
|
+
aos.read_resources_from_array(resource_name, results).each do |resource|
|
46
|
+
yielder << resource
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def list_for resource_url, resource_url_with_dates, resource_name, args = {}
|
52
|
+
# OptOut counting does not work :-( We will have to do the date request to fix this...
|
53
|
+
# If date-arguments are given, we will have to use the date request.
|
54
|
+
if args[:date_from] || args[:date_to] || resource_name == "OptOut"
|
55
|
+
return list_for_with_dates(resource_url_with_dates, resource_name, args)
|
56
|
+
end
|
57
|
+
|
30
58
|
page = 1
|
31
59
|
resource_url = resource_url.gsub("%{send_queue_id}", data(:send_queue_id).to_s)
|
32
60
|
|
33
61
|
if args[:count]
|
34
62
|
resource_url = resource_url.gsub("%{page}", page.to_s).gsub("%{size}", "2")
|
35
|
-
res = aos.req_json(
|
63
|
+
res = aos.req_json(resource_url)
|
36
64
|
return res["Result"]["TotalCount"]
|
37
65
|
end
|
38
66
|
|
39
|
-
|
67
|
+
resource_url = resource_url.gsub("%{size}", "200")
|
40
68
|
|
41
69
|
Enumerator.new do |yielder|
|
42
70
|
loop do
|
43
71
|
resource_url = resource_url.gsub("%{page}", page.to_s)
|
44
|
-
res = aos.req_json(
|
72
|
+
res = aos.req_json(resource_url)
|
45
73
|
|
46
74
|
aos.read_resources_from_array(resource_name, res["Result"]["Items"]).each do |resource|
|
47
75
|
yielder << resource
|
@@ -33,26 +33,20 @@ describe "ApsisOnSteroids" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "#sendings_by_date_interval" do
|
36
|
-
date_from = Date.new(
|
37
|
-
date_to = Date.new(
|
36
|
+
date_from = Date.new(2013, 4, 1)
|
37
|
+
date_to = Date.new(2013, 6, 2)
|
38
38
|
|
39
39
|
list = aos.sendings_by_date_interval(date_from, date_to).to_a
|
40
|
-
list
|
40
|
+
raise "list is empty!?" if list.empty?
|
41
41
|
|
42
42
|
sending = list.first
|
43
43
|
puts "Sending data: #{sending.data_hash}"
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
puts "Click data: #{click.data_hash}"
|
50
|
-
|
51
|
-
open = sending.opens.first
|
52
|
-
puts "Open data: #{open.data_hash}"
|
53
|
-
|
45
|
+
# Test the call doesnt fail.
|
46
|
+
sending.mailing_lists.first
|
47
|
+
sending.clicks.first
|
48
|
+
sending.opens(date_from: date_from, date_to: date_to).first
|
54
49
|
bounce = sending.bounces.first
|
55
|
-
puts "Bounce data: #{bounce.data_hash}"
|
56
50
|
|
57
51
|
opt_outs_count = sending.opt_outs(count: true)
|
58
52
|
puts "Opt outs count: #{opt_outs_count}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apsis-on-steroids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http2
|