textmagic-ruby 2.0.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 +15 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/Makefile +8 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/conf/cacert.pem +3988 -0
- data/examples/bulk_examples.rb +24 -0
- data/examples/chat_examples.rb +30 -0
- data/examples/contact_examples.rb +116 -0
- data/examples/custom_field_examples.rb +78 -0
- data/examples/invoice_examples.rb +26 -0
- data/examples/list_examples.rb +98 -0
- data/examples/message_examples.rb +75 -0
- data/examples/number_examples.rb +72 -0
- data/examples/reply_examples.rb +32 -0
- data/examples/schedule_examples.rb +44 -0
- data/examples/senderid_examples.rb +52 -0
- data/examples/session_examples.rb +51 -0
- data/examples/subaccount_examples.rb +53 -0
- data/examples/template_examples.rb +61 -0
- data/examples/unsubscriber_examples.rb +56 -0
- data/examples/user_examples.rb +105 -0
- data/lib/textmagic-ruby.rb +31 -0
- data/lib/textmagic-ruby/rest/bulks.rb +89 -0
- data/lib/textmagic-ruby/rest/chats.rb +147 -0
- data/lib/textmagic-ruby/rest/client.rb +128 -0
- data/lib/textmagic-ruby/rest/contacts.rb +174 -0
- data/lib/textmagic-ruby/rest/custom_fields.rb +120 -0
- data/lib/textmagic-ruby/rest/errors.rb +14 -0
- data/lib/textmagic-ruby/rest/instance_resource.rb +33 -0
- data/lib/textmagic-ruby/rest/invoices.rb +73 -0
- data/lib/textmagic-ruby/rest/list_resource.rb +64 -0
- data/lib/textmagic-ruby/rest/lists.rb +166 -0
- data/lib/textmagic-ruby/rest/messages.rb +172 -0
- data/lib/textmagic-ruby/rest/numbers.rb +164 -0
- data/lib/textmagic-ruby/rest/paginate_resource.rb +20 -0
- data/lib/textmagic-ruby/rest/replies.rb +85 -0
- data/lib/textmagic-ruby/rest/scheduleds.rb +91 -0
- data/lib/textmagic-ruby/rest/senderids.rb +114 -0
- data/lib/textmagic-ruby/rest/sessions.rb +109 -0
- data/lib/textmagic-ruby/rest/subaccounts.rb +135 -0
- data/lib/textmagic-ruby/rest/templates.rb +107 -0
- data/lib/textmagic-ruby/rest/unsubscribers.rb +85 -0
- data/lib/textmagic-ruby/rest/users.rb +202 -0
- data/lib/textmagic-ruby/rest/utils.rb +48 -0
- data/lib/textmagic-ruby/rest/version.rb +5 -0
- data/spec/rest/client_spec.rb +57 -0
- data/spec/rest/contact_spec.rb +36 -0
- data/spec/rest/custom_fields_spec.rb +36 -0
- data/spec/rest/instance_resource_spec.rb +17 -0
- data/spec/rest/invoice_spec.rb +56 -0
- data/spec/rest/lists_spec.rb +35 -0
- data/spec/rest/message_spec.rb +40 -0
- data/spec/rest/numbers_spec.rb +66 -0
- data/spec/rest/reply_spec.rb +43 -0
- data/spec/rest/scheduled_spec.rb +43 -0
- data/spec/rest/senderid_spec.rb +39 -0
- data/spec/rest/session_spec.rb +43 -0
- data/spec/rest/subaccount_spec.rb +39 -0
- data/spec/rest/template_spec.rb +36 -0
- data/spec/rest/unsubscriber_spec.rb +40 -0
- data/spec/rest/user_spec.rb +92 -0
- data/spec/rest/utils_spec.rb +57 -0
- data/spec/spec_helper.rb +15 -0
- data/textmagic-ruby.gemspec +30 -0
- metadata +165 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Textmagic::REST::Unsubscriber do
|
4
|
+
before do
|
5
|
+
@unsubscriber = Textmagic::REST::Unsubscriber.new 'mockPath', 'mockClient'
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'sets up a client and path' do
|
9
|
+
expect(@unsubscriber.instance_variable_get(:@client)).to eq('mockClient')
|
10
|
+
expect(@unsubscriber.instance_variable_get(:@path)).to eq('mockPath')
|
11
|
+
end
|
12
|
+
|
13
|
+
[:refresh].each do |method|
|
14
|
+
it "should have method #{method}" do
|
15
|
+
expect(@unsubscriber).to respond_to(method)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Textmagic::REST::Unsubscribers do
|
22
|
+
before do
|
23
|
+
@unsubscribers = Textmagic::REST::Unsubscribers.new 'mockPath', 'mockClient'
|
24
|
+
end
|
25
|
+
|
26
|
+
[:list, :get, :update, :create, :delete].each do |method|
|
27
|
+
it "should have method #{method}" do
|
28
|
+
expect(@unsubscribers).to respond_to(method)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should raise RuntimeError if try to call update method' do
|
33
|
+
expect{@unsubscribers.update(1, {})}.to raise_error(RuntimeError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'sets up a client and path' do
|
37
|
+
expect(@unsubscribers.instance_variable_get(:@client)).to eq('mockClient')
|
38
|
+
expect(@unsubscribers.instance_variable_get(:@path)).to eq('mockPath')
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Textmagic::REST::User do
|
4
|
+
before do
|
5
|
+
@user = Textmagic::REST::User.new 'mockPath', 'mockClient'
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'sets up a client and path' do
|
9
|
+
expect(@user.instance_variable_get(:@client)).to eq('mockClient')
|
10
|
+
expect(@user.instance_variable_get(:@path)).to eq('mockPath')
|
11
|
+
end
|
12
|
+
|
13
|
+
[:refresh].each do |method|
|
14
|
+
it "should have method #{method}" do
|
15
|
+
expect(@user).to respond_to(method)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Textmagic::REST::Source do
|
22
|
+
before do
|
23
|
+
@source = Textmagic::REST::Source.new 'mockPath', 'mockClient'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets up a client and path' do
|
27
|
+
expect(@source.instance_variable_get(:@client)).to eq('mockClient')
|
28
|
+
expect(@source.instance_variable_get(:@path)).to eq('mockPath')
|
29
|
+
end
|
30
|
+
|
31
|
+
[:refresh].each do |method|
|
32
|
+
it "should have method #{method}" do
|
33
|
+
expect(@source).to respond_to(method)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should raise RuntimeError if try to call refresh method' do
|
38
|
+
expect{@source.refresh}.to raise_error(RuntimeError)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
describe Textmagic::REST::SpendingStat do
|
44
|
+
before do
|
45
|
+
@stat = Textmagic::REST::SpendingStat.new 'mockPath', 'mockClient'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'sets up a client and path' do
|
49
|
+
expect(@stat.instance_variable_get(:@client)).to eq('mockClient')
|
50
|
+
expect(@stat.instance_variable_get(:@path)).to eq('mockPath')
|
51
|
+
end
|
52
|
+
|
53
|
+
[:refresh].each do |method|
|
54
|
+
it "should have method #{method}" do
|
55
|
+
expect(@stat).to respond_to(method)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should raise RuntimeError if try to call refresh method' do
|
60
|
+
expect{@stat.refresh}.to raise_error(RuntimeError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe Textmagic::REST::Users do
|
65
|
+
before do
|
66
|
+
@users = Textmagic::REST::Users.new 'mockPath', 'mockClient'
|
67
|
+
end
|
68
|
+
|
69
|
+
[:list, :get, :update, :create, :delete, :messaging_stat, :spending_stat, :sources].each do |method|
|
70
|
+
it "should have method #{method}" do
|
71
|
+
expect(@users).to respond_to(method)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should raise RuntimeError if try to call delete method' do
|
76
|
+
expect{@users.delete(1)}.to raise_error(RuntimeError)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should raise RuntimeError if try to call create method' do
|
80
|
+
expect{@users.create({})}.to raise_error(RuntimeError)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should raise RuntimeError if try to call list method' do
|
84
|
+
expect{@users.list}.to raise_error(RuntimeError)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
it 'sets up a client and path' do
|
89
|
+
expect(@users.instance_variable_get(:@client)).to eq('mockClient')
|
90
|
+
expect(@users.instance_variable_get(:@path)).to eq('mockPat')
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Util
|
4
|
+
include Textmagic::REST::Utils
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Util do
|
8
|
+
subject(:util) {Util.new}
|
9
|
+
|
10
|
+
it 'should convert a string to camel case' do
|
11
|
+
expect(util.to_camel_case('first_name')).to eq('FirstName')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should convert hash keys to camel case' do
|
15
|
+
underscore = {
|
16
|
+
:first_name => 'James',
|
17
|
+
:last_name => 'Smith'
|
18
|
+
}
|
19
|
+
camel_case = {
|
20
|
+
:FirstName => 'James',
|
21
|
+
:LastName => 'Smith'
|
22
|
+
}
|
23
|
+
expect(util.to_camel_case(underscore)).to eq(camel_case)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should convert a string to camel case without capitalize' do
|
27
|
+
expect(util.to_camel_case('first_name', false)).to eq('firstName')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should convert hash keys to camel case without capitalize' do
|
31
|
+
underscore = {
|
32
|
+
:first_name => 'James',
|
33
|
+
:last_name => 'Smith'
|
34
|
+
}
|
35
|
+
camel_case = {
|
36
|
+
:firstName => 'James',
|
37
|
+
:lastName => 'Smith'
|
38
|
+
}
|
39
|
+
expect(util.to_camel_case(underscore, false)).to eq(camel_case)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should convert a string to underscore case' do
|
43
|
+
expect(util.to_underscore_case('firstName')).to eq('first_name')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should convert hash keys to underscore case' do
|
47
|
+
camel_case = {
|
48
|
+
:FirstName => 'James',
|
49
|
+
:LastName => 'Smith'
|
50
|
+
}
|
51
|
+
underscore = {
|
52
|
+
:first_name => 'James',
|
53
|
+
:last_name => 'Smith'
|
54
|
+
}
|
55
|
+
expect(util.to_underscore_case(camel_case)).to eq(underscore)
|
56
|
+
end
|
57
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
require 'textmagic-ruby'
|
7
|
+
require 'fakeweb'
|
8
|
+
|
9
|
+
FakeWeb.allow_net_connect = false
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.expect_with :rspec do |c|
|
13
|
+
c.syntax = :expect
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'textmagic-ruby/rest/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'textmagic-ruby'
|
8
|
+
spec.version = Textmagic::REST::VERSION
|
9
|
+
spec.authors = ['Andrey Larionov']
|
10
|
+
spec.email = ['andrey@textmagic.biz']
|
11
|
+
|
12
|
+
spec.summary = %q{TextMagic APIv2 client.}
|
13
|
+
spec.description = %q{TextMagic APIv2 client}
|
14
|
+
spec.homepage = "https://github.com/textmagic/textmagic-rest-ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.required_ruby_version = '>= 1.9.2'
|
21
|
+
|
22
|
+
spec.extra_rdoc_files = ['README.md' ]
|
23
|
+
spec.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'textmagic-ruby', '--main', 'README.md']
|
24
|
+
|
25
|
+
spec.add_dependency('multi_json', '>= 1.5.0')
|
26
|
+
spec.add_dependency('jruby-openssl') if RUBY_PLATFORM == 'java'
|
27
|
+
spec.add_dependency('rubysl') if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: textmagic-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrey Larionov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
description: TextMagic APIv2 client
|
42
|
+
email:
|
43
|
+
- andrey@textmagic.biz
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README.md
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- .rspec
|
51
|
+
- .travis.yml
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- Makefile
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- conf/cacert.pem
|
58
|
+
- examples/bulk_examples.rb
|
59
|
+
- examples/chat_examples.rb
|
60
|
+
- examples/contact_examples.rb
|
61
|
+
- examples/custom_field_examples.rb
|
62
|
+
- examples/invoice_examples.rb
|
63
|
+
- examples/list_examples.rb
|
64
|
+
- examples/message_examples.rb
|
65
|
+
- examples/number_examples.rb
|
66
|
+
- examples/reply_examples.rb
|
67
|
+
- examples/schedule_examples.rb
|
68
|
+
- examples/senderid_examples.rb
|
69
|
+
- examples/session_examples.rb
|
70
|
+
- examples/subaccount_examples.rb
|
71
|
+
- examples/template_examples.rb
|
72
|
+
- examples/unsubscriber_examples.rb
|
73
|
+
- examples/user_examples.rb
|
74
|
+
- lib/textmagic-ruby.rb
|
75
|
+
- lib/textmagic-ruby/rest/bulks.rb
|
76
|
+
- lib/textmagic-ruby/rest/chats.rb
|
77
|
+
- lib/textmagic-ruby/rest/client.rb
|
78
|
+
- lib/textmagic-ruby/rest/contacts.rb
|
79
|
+
- lib/textmagic-ruby/rest/custom_fields.rb
|
80
|
+
- lib/textmagic-ruby/rest/errors.rb
|
81
|
+
- lib/textmagic-ruby/rest/instance_resource.rb
|
82
|
+
- lib/textmagic-ruby/rest/invoices.rb
|
83
|
+
- lib/textmagic-ruby/rest/list_resource.rb
|
84
|
+
- lib/textmagic-ruby/rest/lists.rb
|
85
|
+
- lib/textmagic-ruby/rest/messages.rb
|
86
|
+
- lib/textmagic-ruby/rest/numbers.rb
|
87
|
+
- lib/textmagic-ruby/rest/paginate_resource.rb
|
88
|
+
- lib/textmagic-ruby/rest/replies.rb
|
89
|
+
- lib/textmagic-ruby/rest/scheduleds.rb
|
90
|
+
- lib/textmagic-ruby/rest/senderids.rb
|
91
|
+
- lib/textmagic-ruby/rest/sessions.rb
|
92
|
+
- lib/textmagic-ruby/rest/subaccounts.rb
|
93
|
+
- lib/textmagic-ruby/rest/templates.rb
|
94
|
+
- lib/textmagic-ruby/rest/unsubscribers.rb
|
95
|
+
- lib/textmagic-ruby/rest/users.rb
|
96
|
+
- lib/textmagic-ruby/rest/utils.rb
|
97
|
+
- lib/textmagic-ruby/rest/version.rb
|
98
|
+
- spec/rest/client_spec.rb
|
99
|
+
- spec/rest/contact_spec.rb
|
100
|
+
- spec/rest/custom_fields_spec.rb
|
101
|
+
- spec/rest/instance_resource_spec.rb
|
102
|
+
- spec/rest/invoice_spec.rb
|
103
|
+
- spec/rest/lists_spec.rb
|
104
|
+
- spec/rest/message_spec.rb
|
105
|
+
- spec/rest/numbers_spec.rb
|
106
|
+
- spec/rest/reply_spec.rb
|
107
|
+
- spec/rest/scheduled_spec.rb
|
108
|
+
- spec/rest/senderid_spec.rb
|
109
|
+
- spec/rest/session_spec.rb
|
110
|
+
- spec/rest/subaccount_spec.rb
|
111
|
+
- spec/rest/template_spec.rb
|
112
|
+
- spec/rest/unsubscriber_spec.rb
|
113
|
+
- spec/rest/user_spec.rb
|
114
|
+
- spec/rest/utils_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- textmagic-ruby.gemspec
|
117
|
+
homepage: https://github.com/textmagic/textmagic-rest-ruby
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options:
|
123
|
+
- --line-numbers
|
124
|
+
- --inline-source
|
125
|
+
- --title
|
126
|
+
- textmagic-ruby
|
127
|
+
- --main
|
128
|
+
- README.md
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 1.9.2
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.4.8
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: TextMagic APIv2 client.
|
147
|
+
test_files:
|
148
|
+
- spec/rest/client_spec.rb
|
149
|
+
- spec/rest/contact_spec.rb
|
150
|
+
- spec/rest/custom_fields_spec.rb
|
151
|
+
- spec/rest/instance_resource_spec.rb
|
152
|
+
- spec/rest/invoice_spec.rb
|
153
|
+
- spec/rest/lists_spec.rb
|
154
|
+
- spec/rest/message_spec.rb
|
155
|
+
- spec/rest/numbers_spec.rb
|
156
|
+
- spec/rest/reply_spec.rb
|
157
|
+
- spec/rest/scheduled_spec.rb
|
158
|
+
- spec/rest/senderid_spec.rb
|
159
|
+
- spec/rest/session_spec.rb
|
160
|
+
- spec/rest/subaccount_spec.rb
|
161
|
+
- spec/rest/template_spec.rb
|
162
|
+
- spec/rest/unsubscriber_spec.rb
|
163
|
+
- spec/rest/user_spec.rb
|
164
|
+
- spec/rest/utils_spec.rb
|
165
|
+
- spec/spec_helper.rb
|