mondo 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a86e0346276dc433c2c6656ee8e85a960d7d683
4
- data.tar.gz: 6a84018a4318815baba9c56ae76bb9d880432d50
3
+ metadata.gz: 73cb60edc2f4dee486493b64d6c8de6e5eff108c
4
+ data.tar.gz: f433e07f0b20254482c99e23b3e1a22782787acc
5
5
  SHA512:
6
- metadata.gz: 7e64c21a8a9f55343a9ae3a6e39b52fbb6abd0c66ea08d4096fe5518b0f280cb684e38a4aceca46ce6761c555ee15108d297982eae68e315f7d1d9e9ef0eeb15
7
- data.tar.gz: 53734ac3157c20dddda54190377ba0647b6de6c00e16a5bfb4130e73313d8f4db32e72e9891ac302efb0ca1999438328c9d9e758a523773f1f1330f6ce19c182
6
+ metadata.gz: 37c022a79fda2bdc5d290a67ec6bebedf2eb2273a5db2a6a0c54e98d1fdacf6c45f7485b9666be497b8b36a2b6b5bee97051eb37c1634f9585df73f0b24ada08
7
+ data.tar.gz: 487ecc20d979a8b50c0bf1b4d67af00c01dc8b6baae5806d786ae7932c5d760c9ab9d22fa1831a474d2686345e80c7afc9465c44ea8dcc72f9eb761f1475f239
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.4.2 - September 19, 2015
2
+
3
+ - Added support for registering, listing & deleting web-hooks
4
+
5
+
1
6
  ## 0.4.1 - September 19, 2015
2
7
 
3
8
  - Added support to deregister attachments
data/README.md CHANGED
@@ -85,3 +85,25 @@ tx.register_attachment(
85
85
  # And remove it again
86
86
  tx.attachments.first.deregsiter
87
87
  ```
88
+
89
+
90
+ ## Webhooks
91
+
92
+ ```ruby
93
+ # register a new web-hook
94
+ mondo.register_web_hook("http://google.com")
95
+
96
+ => [#<Mondo::WebHook {"id"=>"webhook_00009258bk4RMBeR4niFFp", "account_id"=>"acc_000091N8nkeAUWHJjR9k9J", "url"=>"http://google.com"}>]
97
+
98
+ # list webhooks
99
+ mondo.web_hooks
100
+
101
+ => [#<Mondo::WebHook {"id"=>"webhook_00009258bk4RMBeR4niFFp", "account_id"=>"acc_000091N8nkeAUWHJjR9k9J", "url"=>"http://google.com"}>]
102
+
103
+ # and remove it
104
+
105
+ mondo.web_hooks.first.delete
106
+
107
+ ```
108
+
109
+
data/lib/mondo/client.rb CHANGED
@@ -123,17 +123,39 @@ module Mondo
123
123
  FeedItem.new(params, self).save
124
124
  end
125
125
 
126
+ def register_web_hook(url)
127
+ raise ClientError.new("You must provide an account id to register webhooks") unless self.account_id
128
+ hook = WebHook.new(
129
+ {
130
+ account_id: self.account_id,
131
+ url: url
132
+ },
133
+ self
134
+ ).save
135
+ @web_hooks << hook
136
+ end
137
+
138
+ def web_hooks
139
+ raise ClientError.new("You must provide an account id to list webhooks") unless self.account_id
140
+ @web_hooks ||= begin
141
+ resp = api_get("webhooks", account_id: self.account_id)
142
+
143
+ puts resp.inspect
144
+
145
+ resp.parsed['webhooks'].map { |hook| WebHook.new(hook, self) }
146
+ end
147
+ end
148
+
126
149
  def user_agent
127
- @user_agent ||=
128
- begin
129
- gem_info = "mondo-ruby/v#{Mondo::VERSION}"
130
- ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
131
- ruby_version = RUBY_VERSION
132
- ruby_version += " p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
133
- comment = ["#{ruby_engine} #{ruby_version}"]
134
- comment << RUBY_PLATFORM if defined?(RUBY_PLATFORM)
135
- "#{gem_info} (#{comment.join("; ")})"
136
- end
150
+ @user_agent ||= begin
151
+ gem_info = "mondo-ruby/v#{Mondo::VERSION}"
152
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
153
+ ruby_version = RUBY_VERSION
154
+ ruby_version += " p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
155
+ comment = ["#{ruby_engine} #{ruby_version}"]
156
+ comment << RUBY_PLATFORM if defined?(RUBY_PLATFORM)
157
+ "#{gem_info} (#{comment.join("; ")})"
158
+ end
137
159
  end
138
160
 
139
161
  # Send a request to the Mondo API servers
@@ -155,8 +177,6 @@ module Mondo
155
177
  opts[:headers]['Content-Type'] = 'application/x-www-form-urlencoded' # sob sob
156
178
  end
157
179
 
158
- puts opts
159
-
160
180
  path = URI.encode(path)
161
181
 
162
182
  resp = connection.run_request(method, path, opts[:body], opts[:headers]) do |req|
data/lib/mondo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mondo
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -0,0 +1,15 @@
1
+ module Mondo
2
+ class WebHook < Resource
3
+
4
+ attr_accessor :id, :account_id, :url
5
+
6
+ def save
7
+ self.client.api_post("webhooks", account_id: account_id, url: url)
8
+ end
9
+
10
+ def delete
11
+ self.client.api_delete("webhooks/#{self.id}")
12
+ true
13
+ end
14
+ end
15
+ end
data/lib/mondo.rb CHANGED
@@ -15,4 +15,5 @@ module Mondo
15
15
  require 'mondo/account'
16
16
  require 'mondo/merchant'
17
17
  require 'mondo/attachment'
18
+ require 'mondo/web_hook'
18
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mondo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Blomfield
@@ -123,6 +123,7 @@ files:
123
123
  - lib/mondo/transaction.rb
124
124
  - lib/mondo/utils.rb
125
125
  - lib/mondo/version.rb
126
+ - lib/mondo/web_hook.rb
126
127
  - mondo.gemspec
127
128
  - spec/client_spec.rb
128
129
  - spec/spec_helper.rb