direct_sms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f04ea0f7b6fddd268fa86242a77714acf8507370
4
+ data.tar.gz: 1118444d144bb0b47209f92b5efc2d82f0223412
5
+ SHA512:
6
+ metadata.gz: 786f6aef3752547bf661eb2eb3145d1a0e49c1a9f6326c72c2a52621cf8d7ced34bed1e70fe95827d5e46dc09a6155a7b28e6f883aed12c7ff507e3d6c27ab37
7
+ data.tar.gz: 4c37f07dc4ff1486a406fe0ddadeafb800fa1c0f708e08069a9485fccd2035f42211e7aabec69b6b6439b304f1e7f6d55fd89162d58a3acab997e972c6fad342
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ /.config
19
+ /coverage/
20
+ /InstalledFiles
21
+ /pkg/
22
+ /spec/reports/
23
+ /test/tmp/
24
+ /test/version_tmp/
25
+ /tmp/
26
+
27
+ ## Specific to RubyMotion:
28
+ .dat*
29
+ .repl_history
30
+ build/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalisation:
39
+ /.bundle/
40
+ /lib/bundler/man/
41
+
42
+ # for a library or gem, you might want to ignore these files since the code is
43
+ # intended to run in multiple environments; otherwise, check them in:
44
+ # Gemfile.lock
45
+ # .ruby-version
46
+ # .ruby-gemset
47
+
48
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
49
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in direct_sms.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Mark
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Mark Chavez
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,29 @@
1
+ # DirectSms
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'direct_sms'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install direct_sms
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/direct_sms ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'direct_sms'
3
+
4
+ sms = DirectSms::Message.new("username", "password", max_segments: 10, type: "2-way")
5
+ sms.to = "+639178574111, +639193963389"
6
+
7
+ puts sms.balance
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'direct_sms/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "direct_sms"
8
+ spec.version = DirectSms::VERSION
9
+ spec.authors = ["Mark Chavez"]
10
+ spec.email = ["markchav3z@gmail.com"]
11
+ spec.summary = %q{Wrapper for DirectSMS API}
12
+ spec.description = %q{Wrapper for DirectSMS API}
13
+ spec.homepage = "https://github.com/mrkjlchvz/directsms"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "webmock"
25
+ spec.add_dependency "httparty"
26
+ end
@@ -0,0 +1,3 @@
1
+ module DirectSms
2
+ VERSION = "0.0.1"
3
+ end
data/lib/direct_sms.rb ADDED
@@ -0,0 +1,33 @@
1
+ require "direct_sms/version"
2
+ require "httparty"
3
+
4
+ module DirectSms
5
+ class Message
6
+ include HTTParty
7
+
8
+ base_uri "api.directsms.com.au"
9
+ attr_accessor :message, :to, :max_segments, :type, :message_id
10
+
11
+ def initialize(username, password, attrs = {})
12
+ @options = { username: username, password: password }
13
+ attrs.each { |k, v| self.send("#{k}=", v) }
14
+ end
15
+
16
+ def balance
17
+ options = { query: @options }
18
+ self.class.get("/s3/http/get_balance", options)
19
+ end
20
+
21
+ def send_message
22
+ options = {
23
+ query: @options.merge(message: @message,
24
+ to: @to,
25
+ max_segments: @max_segments,
26
+ type: @type,
27
+ messageid: @message_id)
28
+ }
29
+
30
+ self.class.get("/s3/http/send_message", options)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'net/http'
3
+
4
+ describe DirectSms do
5
+ let!(:username) { "username" }
6
+ let!(:password) { "password" }
7
+
8
+ describe "balance" do
9
+ it 'returns the remaining balance' do
10
+ stub_request(:get, "http://api.directsms.com.au/s3/http/get_balance?password=#{password}&username=#{username}").
11
+ to_return(:status => 200, :body => "credit: 300.00", :headers => {})
12
+
13
+ sms = DirectSms::Message.new(username, password)
14
+ expect(sms.balance.body).to eq "credit: 300.00"
15
+ end
16
+ end
17
+
18
+ describe "sending sms" do
19
+ it 'attributes can be set on new' do
20
+ sms = DirectSms::Message.new(username, password, :type => "2-way", :max_segments => 20)
21
+
22
+ expect(sms.max_segments).to eq 20
23
+ expect(sms.type).to eq "2-way"
24
+ end
25
+
26
+ it 'sends an sms message' do
27
+ stub_request(:get, "http://api.directsms.com.au/s3/http/send_message?max_segments=10&message=This%20is%20a%20test&password=password&to=%2B639178574111&messageid=&type=2-way&username=username").
28
+ to_return(:status => 200, :body => "id: 1234567890", :headers => {})
29
+
30
+ sms = DirectSms::Message.new(username, password, :type => "2-way", :max_segments => 10)
31
+ sms.message = "This is a test"
32
+ sms.to = "+639178574111"
33
+
34
+ expect(sms.send_message.body).to eq "id: 1234567890"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ require 'bundler/setup'
2
+ require 'webmock/rspec'
3
+
4
+ Bundler.setup
5
+ WebMock.disable_net_connect!(allow_localhost: true)
6
+
7
+ require 'direct_sms'
8
+
9
+ RSpec.configure do |config|
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: direct_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Chavez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-03 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Wrapper for DirectSMS API
84
+ email:
85
+ - markchav3z@gmail.com
86
+ executables:
87
+ - direct_sms
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - Gemfile
94
+ - LICENSE
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/direct_sms
99
+ - direct_sms.gemspec
100
+ - lib/direct_sms.rb
101
+ - lib/direct_sms/version.rb
102
+ - spec/lib/direct_sms_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/mrkjlchvz/directsms
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.0
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Wrapper for DirectSMS API
128
+ test_files:
129
+ - spec/lib/direct_sms_spec.rb
130
+ - spec/spec_helper.rb