sendcloud 0.1.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 +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/lib/sendcloud.rb +54 -0
- data/lib/sendcloud/bounces.rb +23 -0
- data/lib/sendcloud/mail.rb +13 -0
- data/lib/sendcloud/mail_list.rb +41 -0
- data/lib/sendcloud/stats.rb +10 -0
- data/lib/sendcloud/unsubscribes.rb +20 -0
- data/lib/sendcloud/version.rb +3 -0
- data/sendcloud.gemspec +27 -0
- data/spec/bounces_spec.rb +14 -0
- data/spec/mail_list_spec.rb +39 -0
- data/spec/mail_spec.rb +19 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/stats_spec.rb +14 -0
- data/spec/unsubscribes_spec.rb +19 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b84b70203f0aa5c1f57d5f8c3004b82acf08f418
|
4
|
+
data.tar.gz: 1c234f6419566e22d51aefce0c9d2114d8401007
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 26fbb735e661d39472ddd7a36a59c5933b5ebb60e77b90b05b577ca85235bff9db7270ab5528beb22dd7003ccf980b00ce5f66e459e3608ea33e2e9358b3f395
|
7
|
+
data.tar.gz: d1d5f5d28770a133b50331c07a579a41938fc2f1481c5153d5701cb0d83a1a87ba7eb4912a7f136bd1bbedc13ef7f9d1bd26f7e27a7548226837c2cd29f660cc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Haibin Yu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Sendcloud
|
2
|
+
|
3
|
+
Ruby api for sohu sendcloud api
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sendcloud'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sendcloud
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
#### Configure
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
Sendcloud.setup do |config|
|
26
|
+
config.api_user = 'your api user'
|
27
|
+
config.api_key = 'your api key'
|
28
|
+
end
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
#### call the api
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
|
36
|
+
Sendcloud::Mail.send(to: 'test@example.com', from: 'test@example.com', subject: 'test', html: 'test')
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sendcloud.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'sendcloud/mail'
|
3
|
+
require 'sendcloud/mail_list'
|
4
|
+
require 'sendcloud/stats'
|
5
|
+
require 'sendcloud/unsubscribes'
|
6
|
+
require 'sendcloud/bounces'
|
7
|
+
require 'sendcloud/version'
|
8
|
+
|
9
|
+
module Sendcloud
|
10
|
+
|
11
|
+
API_BASE = 'https://sendcloud.sohu.com/webapi'
|
12
|
+
|
13
|
+
class Error < StandardError; end
|
14
|
+
|
15
|
+
def self.setup
|
16
|
+
yield self
|
17
|
+
end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :api_user, :api_key, :format
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.get(path, params)
|
24
|
+
|
25
|
+
request(path, params) do |url, options|
|
26
|
+
RestClient.get(url, {:params => options})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.post(path, params)
|
31
|
+
|
32
|
+
request(path, params) do |url, options|
|
33
|
+
RestClient.post(url, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.request(path, params, &block)
|
39
|
+
params = {
|
40
|
+
:api_user => Sendcloud.api_user,
|
41
|
+
:api_key => Sendcloud.api_key,
|
42
|
+
}.merge(params)
|
43
|
+
|
44
|
+
format = params.delete(:format) || 'json'
|
45
|
+
url = "#{API_BASE}/#{path}.#{format}"
|
46
|
+
begin
|
47
|
+
return JSON.parse(yield(url, params))
|
48
|
+
rescue JSON::ParserError
|
49
|
+
raise Sendcloud::Error.new('sendcloud response invalid')
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sendcloud
|
2
|
+
module Bounces
|
3
|
+
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def get(params)
|
7
|
+
Sendcloud.get('bounces.get', params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete(params)
|
11
|
+
Sendcloud.post('bounces.delete', params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def count(params)
|
15
|
+
Sendcloud.get('bounces.count', params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add(params)
|
19
|
+
Sendcloud.post('bounces.add', params)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Sendcloud
|
2
|
+
|
3
|
+
module MailList
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def create(params)
|
8
|
+
Sendcloud.post('list.create', params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(params)
|
12
|
+
Sendcloud.get('list.get', params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete(params)
|
16
|
+
Sendcloud.get('list.delete', params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(params)
|
20
|
+
Sendcloud.post('list.update', params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def member_add(params)
|
24
|
+
Sendcloud.post('list_member.add', params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def member_delete(params)
|
28
|
+
Sendcloud.post('list_member.delete', params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def member_get(params)
|
32
|
+
Sendcloud.get('list_member.get', params)
|
33
|
+
end
|
34
|
+
|
35
|
+
def member_update(params)
|
36
|
+
Sendcloud.post('list_member.update', params)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Sendcloud
|
2
|
+
|
3
|
+
module Unsubscribes
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def get(params)
|
8
|
+
Sendcloud.get('unsubscribes.get', params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete(params)
|
12
|
+
Sendcloud.post('unsubscribes.delete', params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def add(params)
|
16
|
+
Sendcloud.post('unsubscribes.add', params)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/sendcloud.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sendcloud/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'sendcloud'
|
8
|
+
spec.version = Sendcloud::VERSION
|
9
|
+
spec.authors = ['Haibin Yu']
|
10
|
+
spec.email = ['seashineyu@gmail.com']
|
11
|
+
spec.description = %q{ruby client for sohu sendcloud api}
|
12
|
+
spec.summary = %q{use this gem to call sohu sendcloud api}
|
13
|
+
spec.homepage = 'http://78jian.com'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 2.4'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
|
25
|
+
spec.add_dependency 'rest-client', '> 1.6.0'
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
describe Sendcloud::Bounces do
|
4
|
+
|
5
|
+
describe 'get' do
|
6
|
+
|
7
|
+
it 'should return success' do
|
8
|
+
response = Sendcloud::Bounces.get(days: 2)
|
9
|
+
expect(response['message']).to eq('success')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
|
4
|
+
describe Sendcloud::MailList do
|
5
|
+
|
6
|
+
describe 'create' do
|
7
|
+
it 'should return success' do
|
8
|
+
response = Sendcloud::MailList.create({
|
9
|
+
:address => 'test-sj@78jian.sendcloud.org',
|
10
|
+
:name => 'test mail list',
|
11
|
+
:description => 'test mail list'
|
12
|
+
})
|
13
|
+
expect(response['message']).to eq('success')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'create' do
|
18
|
+
it 'should return success' do
|
19
|
+
response = Sendcloud::MailList.member_add({
|
20
|
+
:mail_list_addr => 'test-sj@78jian.sendcloud.org',
|
21
|
+
:member_addr => 'test@test.org',
|
22
|
+
:name => 'test user'
|
23
|
+
})
|
24
|
+
expect(response['message']).to eq('success')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'delete' do
|
29
|
+
it 'should return success' do
|
30
|
+
response = Sendcloud::MailList.member_delete({
|
31
|
+
:mail_list_addr => 'test-sj@78jian.sendcloud.org',
|
32
|
+
:member_addr => 'test@test.org'
|
33
|
+
})
|
34
|
+
expect(response['message']).to eq('success')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
data/spec/mail_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
describe Sendcloud::Mail do
|
4
|
+
|
5
|
+
describe 'send' do
|
6
|
+
|
7
|
+
it 'should return success' do
|
8
|
+
response = Sendcloud::Mail.send({
|
9
|
+
:to => '272056334@qq.com',
|
10
|
+
:from => 'notification@78jian.com',
|
11
|
+
:subject => 'test',
|
12
|
+
:html => 'rspec test'
|
13
|
+
})
|
14
|
+
expect(response['message']).to eq('success')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/stats_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
describe Sendcloud::Stats do
|
4
|
+
|
5
|
+
describe 'get' do
|
6
|
+
|
7
|
+
it 'should return success' do
|
8
|
+
response = Sendcloud::Stats.get(days: 2, aggregate: 1)
|
9
|
+
expect(response['message']).to eq('success')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../spec_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
describe Sendcloud::Stats do
|
4
|
+
|
5
|
+
describe 'get' do
|
6
|
+
it 'should return success' do
|
7
|
+
response = Sendcloud::Unsubscribes.get(days: 2)
|
8
|
+
expect(response['message']).to eq('success')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'add' do
|
13
|
+
it 'should return success' do
|
14
|
+
response = Sendcloud::Unsubscribes.get(email: 'test-delete@test.org')
|
15
|
+
expect(response['message']).to eq('success')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sendcloud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Haibin Yu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.0
|
69
|
+
description: ruby client for sohu sendcloud api
|
70
|
+
email:
|
71
|
+
- seashineyu@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/sendcloud.rb
|
83
|
+
- lib/sendcloud/bounces.rb
|
84
|
+
- lib/sendcloud/mail.rb
|
85
|
+
- lib/sendcloud/mail_list.rb
|
86
|
+
- lib/sendcloud/stats.rb
|
87
|
+
- lib/sendcloud/unsubscribes.rb
|
88
|
+
- lib/sendcloud/version.rb
|
89
|
+
- sendcloud.gemspec
|
90
|
+
- spec/bounces_spec.rb
|
91
|
+
- spec/mail_list_spec.rb
|
92
|
+
- spec/mail_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
- spec/stats_spec.rb
|
95
|
+
- spec/unsubscribes_spec.rb
|
96
|
+
homepage: http://78jian.com
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.0.rc.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: use this gem to call sohu sendcloud api
|
120
|
+
test_files:
|
121
|
+
- spec/bounces_spec.rb
|
122
|
+
- spec/mail_list_spec.rb
|
123
|
+
- spec/mail_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
- spec/stats_spec.rb
|
126
|
+
- spec/unsubscribes_spec.rb
|