bitballoon 0.0.11 → 0.1.0

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitballoon (0.0.4)
4
+ bitballoon (0.0.11)
5
5
  highline
6
6
  oauth2 (>= 0.9.2)
7
7
  slop
@@ -13,12 +13,12 @@ GEM
13
13
  crack (0.3.2)
14
14
  faraday (0.8.8)
15
15
  multipart-post (~> 1.2.0)
16
- highline (1.6.14)
16
+ highline (1.6.20)
17
17
  httpauth (0.2.0)
18
18
  jwt (0.1.8)
19
19
  multi_json (>= 1.5)
20
20
  minitest (5.0.8)
21
- multi_json (1.8.0)
21
+ multi_json (1.8.2)
22
22
  multi_xml (0.5.5)
23
23
  multipart-post (1.2.0)
24
24
  oauth2 (0.9.2)
@@ -29,7 +29,7 @@ GEM
29
29
  multi_xml (~> 0.5)
30
30
  rack (~> 1.2)
31
31
  rack (1.5.2)
32
- slop (3.4.3)
32
+ slop (3.4.6)
33
33
  webmock (1.11.0)
34
34
  addressable (>= 2.2.7)
35
35
  crack (>= 0.3.2)
data/README.md CHANGED
@@ -149,7 +149,7 @@ site.wait_for_ready
149
149
  Update the name of the site (its subdomain), the custom domain and the notification email for form submissions:
150
150
 
151
151
  ```ruby
152
- site.update(:name => "my-site", :custom_domain => "www.example.com", :notification_email => "me@example.com")
152
+ site.update(:name => "my-site", :custom_domain => "www.example.com", :notification_email => "me@example.com", :password => "secret-password")
153
153
  ```
154
154
 
155
155
  Deleting a site:
@@ -158,6 +158,74 @@ Deleting a site:
158
158
  site.destroy!
159
159
  ```
160
160
 
161
+ Deploys
162
+ =======
163
+
164
+ Access all deploys for a site
165
+
166
+ ```ruby
167
+ site = bitballoon.sites.get(site_id)
168
+ site.deploys.all
169
+ ```
170
+
171
+ Access a specific deploy
172
+
173
+ ```ruby
174
+ site = bitballoon.sites.get(site_id)
175
+ site.deploys.get(id)
176
+ ```
177
+
178
+ Restore a deploy (makes it the current live version of the site)
179
+
180
+ ```ruby
181
+ site.deploys.get(id).restore
182
+ ```
183
+
184
+ Users
185
+ =====
186
+
187
+ Access all users you have access to
188
+
189
+ ```ruby
190
+ bitballoon.users.all
191
+ ```
192
+
193
+ Access a specific user
194
+
195
+ ```ruby
196
+ bitballoon.users.get(id)
197
+ ```
198
+
199
+ Create a user. **Reseller only**. A unique email is required. You can optionally include a unique uid, typically the database ID you use for the user on your end.
200
+
201
+ ```ruby
202
+ bitballoon.users.create(:email => "some@email.com", :uid => "12345")
203
+ ```
204
+
205
+ Update a user. **Reseller only**.
206
+
207
+ ```ruby
208
+ bitballoon.users.get(id).update(:email => "new@email.com", :uid => "12345")
209
+ ```
210
+
211
+ Delete a user. **Reseller only**
212
+
213
+ ```ruby
214
+ bitballoon.users.get(id).destroy
215
+ ```
216
+
217
+ Get all sites for a user
218
+
219
+ ```ruby
220
+ bitballoon.users.get(id).sites
221
+ ```
222
+
223
+ Get all form submissions for a user
224
+
225
+ ```ruby
226
+ bitballoon.users.get(id).submissions
227
+ ```
228
+
161
229
  Forms
162
230
  =====
163
231
 
@@ -234,12 +302,45 @@ Snippets
234
302
  Snippets are small code snippets injected into all HTML pages of a site right before the closing head or body tag. To get all snippets for a site:
235
303
 
236
304
  ```ruby
237
- site = bitballoon.sites.get(id)
238
- site.snippets.all
305
+ site = bitballoon.sites.get(id)
306
+ site.snippets.all
239
307
  ```
240
308
 
241
309
  Get a specific snippet
242
310
 
243
311
  ```ruby
244
- site.snippets.get(0)
245
- ```
312
+ site.snippets.get(0)
313
+ ```
314
+
315
+ Add a snippet to a site.
316
+
317
+ You can specify a `general` snippet that will be inserted into all pages, and a `goal` snippet that will be injected into a page following a successful form submission. Each snippet must have a title. You can optionally set the position of both the general and the goal snippet to `head` or `footer` to determine if it gets injected into the head tag or at the end of the page.
318
+
319
+ ```ruby
320
+ site.snippets.create(
321
+ :general => general_snippet,
322
+ :general_position => "footer",
323
+ :goal => goal_snippet,
324
+ :goal_position => "head",
325
+ :title => "My Snippet"
326
+ )
327
+ ```
328
+
329
+ Update a snippet
330
+
331
+ ```ruby
332
+ site.snippets.get(id).update(
333
+ :general => general_snippet,
334
+ :general_position => "footer",
335
+ :goal => goal_snippet,
336
+ :goal_position => "head",
337
+ :title => "My Snippet"
338
+ )
339
+ ```
340
+
341
+ Remove a snippet
342
+
343
+ ```ruby
344
+ site.snippet.get(id).destroy
345
+ end
346
+ ```
data/lib/bitballoon.rb CHANGED
@@ -8,6 +8,7 @@ require "bitballoon/forms"
8
8
  require "bitballoon/submissions"
9
9
  require "bitballoon/files"
10
10
  require "bitballoon/snippets"
11
+ require "bitballoon/users"
11
12
  require "bitballoon/deploys"
12
13
  require "bitballoon/multipass"
13
14
 
@@ -51,6 +51,10 @@ module BitBalloon
51
51
  Submissions.new(self)
52
52
  end
53
53
 
54
+ def users
55
+ Users.new(self)
56
+ end
57
+
54
58
  def request(verb, path, opts={}, &block)
55
59
  retries = 0
56
60
  begin
@@ -18,8 +18,8 @@ module BitBalloon
18
18
  self.prefix = prefix
19
19
  end
20
20
 
21
- def all
22
- response = client.request(:get, [prefix, path].compact.join("/"))
21
+ def all(options = {})
22
+ response = client.request(:get, [prefix, path].compact.join("/"), {:params => options})
23
23
  response.parsed.map {|attributes| model.new(client, attributes) } if response.parsed
24
24
  end
25
25
 
@@ -32,6 +32,11 @@ module BitBalloon
32
32
  model.new(client, response.parsed) if response.parsed
33
33
  end
34
34
 
35
+ def create(attributes)
36
+ response = client.request(:post, path, attributes)
37
+ model.new(client, response.parsed) if response.parsed
38
+ end
39
+
35
40
  def model
36
41
  self.class.model
37
42
  end
@@ -39,6 +39,15 @@ module BitBalloon
39
39
  self
40
40
  end
41
41
 
42
+ def update(attributes)
43
+ response = client.request(:put, path, attributes)
44
+ process(response.parsed) if response.parsed
45
+ end
46
+
47
+ def destroy
48
+ client.request(:delete, path)
49
+ end
50
+
42
51
  def refresh
43
52
  response = client.request(:get, path)
44
53
  process(response.parsed)
@@ -82,6 +82,10 @@ module BitBalloon
82
82
  Snippets.new(client, path)
83
83
  end
84
84
 
85
+ def deploys
86
+ Deploys.new(client, path)
87
+ end
88
+
85
89
  private
86
90
  def mutable_attributes(attributes)
87
91
  Hash[*[:name, :custom_domain, :password, :notification_email].map {|key|
@@ -10,16 +10,17 @@ module BitBalloon
10
10
  path = site_id ? "/sites/#{site_id}" : "/sites"
11
11
  method = site_id ? :put : :post
12
12
  if attributes[:dir]
13
- dir = attributes[:dir]
14
- response = client.request(method, path, :body => JSON.generate({:files => inventory(dir)}), :headers => {"Content-Type" => "application/json"})
13
+ dir = attributes.delete(:dir)
14
+ response = client.request(method, path, :body => JSON.generate(attributes.merge(:files => inventory(dir))), :headers => {"Content-Type" => "application/json"})
15
15
  Site.new(client, response.parsed).tap do |site|
16
16
  site.upload_dir(dir)
17
17
  end
18
18
  elsif attributes[:zip]
19
- ::File.open(attributes[:zip]) do |file|
20
- response = client.request(method, path, :body => {
19
+ zip = attributes.delete(:zip)
20
+ ::File.open(zip) do |file|
21
+ response = client.request(method, path, :body => attributes.merge(
21
22
  :zip => Faraday::UploadIO.new(file, 'application/zip')
22
- })
23
+ ))
23
24
  Site.new(client, response.parsed)
24
25
  end
25
26
  end
@@ -0,0 +1,17 @@
1
+ module BitBalloon
2
+ class User < Model
3
+ fields :id, :uid, :email, :affiliate_id, :site_count, :created_at, :last_login
4
+
5
+ def sites
6
+ Sites.new(client, path)
7
+ end
8
+
9
+ def submissions
10
+ Submissions.new(client, path)
11
+ end
12
+
13
+ def forms
14
+ Forms.new(client, path)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require "bitballoon/user"
2
+
3
+ module BitBalloon
4
+ class Users < CollectionProxy
5
+ path "/users"
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module BitBalloon
2
- VERSION = "0.0.11"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitballoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-24 00:00:00.000000000 Z
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -123,6 +123,8 @@ files:
123
123
  - lib/bitballoon/snippets.rb
124
124
  - lib/bitballoon/submission.rb
125
125
  - lib/bitballoon/submissions.rb
126
+ - lib/bitballoon/user.rb
127
+ - lib/bitballoon/users.rb
126
128
  - lib/bitballoon/version.rb
127
129
  - test/client_test.rb
128
130
  - test/files/site-dir.zip