emailyak 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/emailyak.rb +15 -16
  2. data/lib/emailyak/version.rb +1 -1
  3. metadata +1 -1
@@ -1,8 +1,7 @@
1
1
  require 'cgi'
2
2
  require 'set'
3
-
4
3
  require 'rubygems'
5
- require 'json/pure'
4
+ require 'multi_json'
6
5
  require 'openssl'
7
6
  require 'rest_client'
8
7
  require 'ostruct'
@@ -10,8 +9,8 @@ require 'ostruct'
10
9
  # A lot of the structure here is borrowed from the Stripe Ruby
11
10
  # bindings (https://github.com/stripe/stripe-ruby).
12
11
 
13
- # Further adapted from https://github.com/gdb/emailyak-ruby
14
- # because I couldn't get it to install on heroku and
12
+ # Further adapted from https://github.com/gdb/emailyak-ruby
13
+ # because I couldn't get it to install on heroku and
15
14
  # I wanted to add to it
16
15
 
17
16
  module EmailYak
@@ -32,7 +31,7 @@ module EmailYak
32
31
  end
33
32
  end
34
33
  end
35
-
34
+
36
35
  def self.docs(url=self.api_docs_url)
37
36
  begin
38
37
  puts "opening api docs at #{self.api_docs_url} "
@@ -42,7 +41,7 @@ module EmailYak
42
41
  end
43
42
  true
44
43
  end
45
-
44
+
46
45
  def self.api_docs_url
47
46
  "http://docs.emailyak.com/"
48
47
  end
@@ -72,40 +71,40 @@ module EmailYak
72
71
  def self.all(params={})
73
72
  EmailYak.request(:get, 'get/all/email/', nil, params)
74
73
  end
75
-
74
+
76
75
  def self.get(params={})
77
76
  EmailYak.request(:get, 'get/email/', nil, params)
78
77
  end
79
-
78
+
80
79
  def self.list(params={})
81
80
  EmailYak.request(:get, 'get/email/list/', nil, params)
82
81
  end
83
-
82
+
84
83
  def self.new(params={})
85
84
  EmailYak.request(:get, 'get/new/email/', nil, params)
86
85
  end
87
-
86
+
88
87
  def self.send(params={})
89
88
  EmailYak.request(:post, 'send/email/', nil, params)
90
89
  end
91
-
90
+
92
91
  def self.delete(params={})
93
92
  EmailYak.request(:post, 'delete/email/', nil, params)
94
93
  end
95
94
  end
96
-
95
+
97
96
  module Address
98
97
  def self.register(address, callback_url, push=true)
99
98
  EmailYak.request(:post, 'register/address/', nil, {"PushEmail" => push, "Address" => address, "CallbackURL" => callback_url})
100
99
  end
101
100
  end
102
-
101
+
103
102
  module Domain
104
103
  def self.register(params={})
105
104
  EmailYak.request(:post, 'register/domain/', nil, params)
106
105
  end
107
106
  end
108
-
107
+
109
108
  def self.request(method, url, api_key, params=nil, headers={})
110
109
  api_key ||= @@api_key
111
110
  raise EmailYakError.new('No API key provided. (HINT: set your API key using "EmailYak.api_key = <API-KEY>".') unless api_key
@@ -136,7 +135,7 @@ module EmailYak
136
135
  payload = nil
137
136
  else
138
137
  headers = {:content_type => 'application/json'}
139
- payload = JSON.generate(params)
138
+ payload = MultiJson.dump(params)
140
139
  end
141
140
  opts = {
142
141
  :method => method,
@@ -173,7 +172,7 @@ module EmailYak
173
172
  rbody = response.body
174
173
  rcode = response.code
175
174
  begin
176
- resp = JSON.parse(rbody)
175
+ resp = MultiJson.load(rbody)
177
176
  rescue
178
177
  raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})")
179
178
  end
@@ -1,3 +1,3 @@
1
1
  module Emailyak
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailyak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: