mondo 0.4.1 → 0.4.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +22 -0
- data/lib/mondo/client.rb +32 -12
- data/lib/mondo/version.rb +1 -1
- data/lib/mondo/web_hook.rb +15 -0
- data/lib/mondo.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73cb60edc2f4dee486493b64d6c8de6e5eff108c
|
4
|
+
data.tar.gz: f433e07f0b20254482c99e23b3e1a22782787acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c022a79fda2bdc5d290a67ec6bebedf2eb2273a5db2a6a0c54e98d1fdacf6c45f7485b9666be497b8b36a2b6b5bee97051eb37c1634f9585df73f0b24ada08
|
7
|
+
data.tar.gz: 487ecc20d979a8b50c0bf1b4d67af00c01dc8b6baae5806d786ae7932c5d760c9ab9d22fa1831a474d2686345e80c7afc9465c44ea8dcc72f9eb761f1475f239
|
data/CHANGELOG.md
CHANGED
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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
@@ -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
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.
|
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
|