ruby-sendhub 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/lib/ruby-sendhub/version.rb +5 -0
- data/lib/ruby-sendhub.rb +38 -0
- data/ruby-sendhub.gemspec +26 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# ruby-sendhub
|
2
|
+
|
3
|
+
ruby-sendhub is a simple API wrapper for interacting with [SendHub API](http://www.sendhub.com/developer)
|
4
|
+
|
5
|
+
##Installation
|
6
|
+
|
7
|
+
$ gem install ruby-sendhub
|
8
|
+
|
9
|
+
##Requirements
|
10
|
+
|
11
|
+
A SendHub account. Get your API key [here](https://www.sendhub.com/settings)
|
12
|
+
|
13
|
+
##Usage
|
14
|
+
|
15
|
+
Currently, only two methods are implemented as this is my first Gem ever. Woohoo! "cries"
|
16
|
+
|
17
|
+
Create a new instance of the API wrapper:
|
18
|
+
|
19
|
+
sh = SendHub.new("your_api_key", "your_number")
|
20
|
+
|
21
|
+
Now you grab the contacts you have. You need the contact id to send any message
|
22
|
+
|
23
|
+
sh.get_contacts
|
24
|
+
|
25
|
+
Once you grabbed the contacts you can send messages to the contact(s) by
|
26
|
+
|
27
|
+
sh.send_message("Your message here", *id)
|
28
|
+
|
29
|
+
##Special Thanks
|
30
|
+
|
31
|
+
* My mom and dad, seriously, first gem you know
|
32
|
+
* [Amro Mousa](https://github.com/amro) for his source code on Gibbon which inspired this code
|
33
|
+
|
34
|
+
##License
|
35
|
+
|
36
|
+
No time for this, just do whatever you want
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/ruby-sendhub.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "ruby-sendhub/version"
|
2
|
+
require 'httparty'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class SendHub
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
attr_accessor :api_key, :number
|
9
|
+
|
10
|
+
headers "Content-Type" => "application/json"
|
11
|
+
|
12
|
+
def initialize(api_key = nil, number = nil)
|
13
|
+
@number = number
|
14
|
+
@api_key = api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_contacts
|
18
|
+
c = self.class.get base_url + "contacts" + credentials
|
19
|
+
c.parsed_response['objects']
|
20
|
+
end
|
21
|
+
|
22
|
+
def send_message(message, *args)
|
23
|
+
api_url = base_url + "messages" + credentials
|
24
|
+
m = { :contacts => args, :text => message }
|
25
|
+
self.class.post(api_url, :body => m.to_json)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def base_url
|
31
|
+
"https://api.sendhub.com/v1/"
|
32
|
+
end
|
33
|
+
|
34
|
+
def credentials
|
35
|
+
"/?username=#{number}&api_key=#{api_key}"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ruby-sendhub/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ruby-sendhub"
|
7
|
+
s.version = Ruby::Sendhub::VERSION
|
8
|
+
s.authors = ["SoonKhen OwYong"]
|
9
|
+
s.email = ["dude@owyong.sk"]
|
10
|
+
s.homepage = "https://github.com/skowyong/ruby-sendhub"
|
11
|
+
s.summary = %q{A simple Ruby wrapper for SendHub API}
|
12
|
+
s.description = %q{My first gem and no tests yet. Ruby wrapper for SendHub API}
|
13
|
+
|
14
|
+
s.rubyforge_project = "ruby-sendhub"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
|
24
|
+
s.add_runtime_dependency "httparty"
|
25
|
+
s.add_runtime_dependency "json"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-sendhub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SoonKhen OwYong
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &14589000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14589000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &14588400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14588400
|
36
|
+
description: My first gem and no tests yet. Ruby wrapper for SendHub API
|
37
|
+
email:
|
38
|
+
- dude@owyong.sk
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- lib/ruby-sendhub.rb
|
48
|
+
- lib/ruby-sendhub/version.rb
|
49
|
+
- ruby-sendhub.gemspec
|
50
|
+
homepage: https://github.com/skowyong/ruby-sendhub
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: ruby-sendhub
|
70
|
+
rubygems_version: 1.8.17
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A simple Ruby wrapper for SendHub API
|
74
|
+
test_files: []
|