ruby-sendhub 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # ruby-sendhub
2
2
 
3
3
  ruby-sendhub is a simple API wrapper for interacting with [SendHub API](http://www.sendhub.com/developer)
4
+ It's my first ever gem, so I'm crying right now as you read this.
4
5
 
5
6
  ##Installation
6
7
 
@@ -12,23 +13,21 @@ A SendHub account. Get your API key [here](https://www.sendhub.com/settings)
12
13
 
13
14
  ##Usage
14
15
 
15
- Currently, only three methods are implemented as this is my first Gem ever. Woohoo! "cries"
16
-
17
16
  Create a new instance of the API wrapper:
18
17
 
19
18
  sh = SendHub.new("your_api_key", "your_number")
20
19
 
21
- Now you grab the contacts you have. You need the contact id to send any message
20
+ As a simple example, to grab all of your contacts
22
21
 
23
22
  sh.get_contacts
24
23
 
25
- Or grab all the groups
24
+ SendHub API uses RESTful services. Every methods begin with post, put, update, or delete and their resources. A more advanced example:
26
25
 
27
- sh.get_groups
26
+ sh.post_contacts({:name => "SoonKhen OwYong", :number => 4040404040, :address => "1 Infinite Loop", :city => "Cupertino", :zip => "95014"})
28
27
 
29
- Once you grabbed the contacts you can send messages to the contact(s) or group(s) by
28
+ Every put or delete requests must have :id in it
30
29
 
31
- sh.send_message("Your message here", *group_ids, *contact_ids)
30
+ sh.delete_contacts({:id => [11]})
32
31
 
33
32
  ##Special Thanks
34
33
 
data/lib/ruby-sendhub.rb CHANGED
@@ -14,26 +14,15 @@ class SendHub
14
14
  @api_key = api_key
15
15
  end
16
16
 
17
- def get_contacts
18
- c = self.class.get base_url + "contacts" + credentials
19
- c.parsed_response['objects']
20
- end
21
-
22
- def get_groups
23
- c = self.class.get base_url + "groups" + credentials
24
- c.parsed_response['objects']
25
- end
26
-
27
- def add_contacts(name, number)
28
- api_url = base_url + "contacts" + credentials
29
- m = { :name => name, :number => number.to_s }
30
- self.class.post(api_url, :body => m.to_json)
31
- end
32
-
33
- def send_message(message, *args)
34
- api_url = base_url + "messages" + credentials
35
- m = { :contacts => args, :text => message }
36
- self.class.post(api_url, :body => m.to_json)
17
+ def method_missing(method, hsh = {})
18
+ meth = method.to_s.split("_")
19
+ if meth.first == "put" || meth.first == "delete"
20
+ api_url = base_url + meth.last + "/" + hsh[:id].to_s + credentials
21
+ else
22
+ api_url = base_url + meth.last + credentials
23
+ end
24
+ ret = self.class.send(meth.first, api_url, :body => hsh.to_json).parsed_response
25
+ ret.nil? && meth.first == "delete" ? "Aaaand it's gone" : ret
37
26
  end
38
27
 
39
28
  private
@@ -1,5 +1,5 @@
1
1
  module Ruby
2
2
  module Sendhub
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-sendhub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &6545780 !ruby/object:Gem::Requirement
16
+ requirement: &19992840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6545780
24
+ version_requirements: *19992840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &6544600 !ruby/object:Gem::Requirement
27
+ requirement: &19989000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *6544600
35
+ version_requirements: *19989000
36
36
  description: My first gem and no tests yet. Ruby wrapper for SendHub API
37
37
  email:
38
38
  - dude@owyong.sk