inbox 0.13.0 → 0.14.0

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: 62b688d40a00847715b2f3b2ee9d34cdd0e527fc
4
- data.tar.gz: 1b7524aed2682373ffb6e5895932a3aa91d56e27
3
+ metadata.gz: b5c174c3fd4fd1cad46d27b002e1e881d3d374fd
4
+ data.tar.gz: 12fb8ec8381a6e47de38aacbf844d58515741d3c
5
5
  SHA512:
6
- metadata.gz: 64aa478e4dae71a8eaf84ca91b9e976936acf370469f8cab5c31b941782b23ae93b82b3c3349441585723fdfa353a07034ff44401ca8a6d93e2505cf0d2003ca
7
- data.tar.gz: 948f917c9bbcf97c9ebd74437263a3d0c94bf34bdb735880b567f87dc0e9f5b8395325fc40cc37811bb17e1f08c25dd56385895e4fce7e47abece2dcfc41253e
6
+ metadata.gz: 8f3cc95868344d89c6c3a79d6bde051f0a151f0422cf4ab8ed88d7e264a3732bf503457a686b5d6cf1fead0354b58b15fd139574c8299eccc89c407d930415db
7
+ data.tar.gz: 30f95170b47ed231dd1254313cd3b56dc9dd29011e5f8ebeec0e07cb08c04c357ee946ce045cbb4d1cb2fb029868a40d0cb69b8daed38bb72dd4403996b8fe86
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Inbox Ruby bindings
1
+ # Nilas REST API Ruby bindings
2
2
 
3
3
  ## Installation
4
4
 
@@ -24,7 +24,7 @@ You don't need to use this repo unless you're planning to modify the gem. If you
24
24
 
25
25
  ## Example Rails App
26
26
 
27
- A small example Rails app is included in the `example` directory. You can run the sample app to see how an authentication flow might be implemented.
27
+ A small example Rails app is included in the `example` directory. You can run the sample app to see how an authentication flow might be implemented.
28
28
 
29
29
  `cd example`
30
30
 
@@ -36,16 +36,16 @@ A small example Rails app is included in the `example` directory. You can run th
36
36
 
37
37
  ### App ID and Secret
38
38
 
39
- Before you can interact with the Inbox API, you need to register for the Inbox Developer Program at [http://www.inboxapp.com/](http://www.inboxapp.com/). After you've created a developer account, you can create a new application to generate an App ID / Secret pair.
39
+ Before you can interact with the Inbox API, you need to register for the Nilas Developer Program at [https://www.nilas.com/](https://www.nilas.com/). After you've created a developer account, you can create a new application to generate an App ID / Secret pair.
40
40
 
41
41
  Generally, you should store your App ID and Secret into environment variables to avoid adding them to source control. That said, in the example project and code snippets below, the values were added to `config/environments/development.rb` for convenience.
42
42
 
43
43
 
44
44
  ### Authentication
45
45
 
46
- The Inbox API uses server-side (three-legged) OAuth, and the Ruby gem provides convenience methods that simplify the OAuth process. For more information about authenticating with Inbox, visit the [Developer Documentation](https://www.inboxapp.com/docs/gettingstarted-hosted#authenticating).
46
+ The Nilas REST API uses server-side (three-legged) OAuth, and the Ruby gem provides convenience methods that simplify the OAuth process. For more information about authenticating with Nilas, visit the [Developer Documentation](https://www.nilas.com/docs/gettingstarted-hosted#authenticating).
47
47
 
48
- **Step 1: Redirect the user to Inbox:**
48
+ **Step 1: Redirect the user to Nilas:**
49
49
 
50
50
  ```ruby
51
51
  require 'inbox'
@@ -53,11 +53,11 @@ require 'inbox'
53
53
  def login
54
54
  inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, nil)
55
55
  # The email address of the user you want to authenticate
56
- user_email = 'ben@inboxapp.com'
56
+ user_email = 'ben@nilas.com'
57
57
 
58
58
  # This URL must be registered with your application in the developer portal
59
59
  callback_url = url_for(:action => 'login_callback')
60
-
60
+
61
61
  redirect_to inbox.url_for_authentication(callback_url, user_email)
62
62
  end
63
63
  ```
@@ -65,7 +65,7 @@ end
65
65
  **Step 2: Handle the Authentication Response:**
66
66
 
67
67
  ```ruby
68
- def login_callback
68
+ def login_callback
69
69
  inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, nil)
70
70
  inbox_token = inbox.token_for_code(params[:code])
71
71
 
@@ -75,11 +75,11 @@ end
75
75
 
76
76
  ### Managing Billing
77
77
 
78
- If you're using the open-source version of the Inbox API or have fewer than 10 accounts associated with your developer app, you don't need to worry about billing. However, if you've requested production access to the Inbox API, you are billed monthly based on the number of email accounts you've connected to Inbox. You can choose to start accounts in "trial" state and sync slowly at a rate of one message per minute so users can try out your app. If you use trial mode, you need to upgrade accounts (and start paying for them) within 30 days or they will automatically expire. You may wish to upgrade accounts earlier to dramatically speed up the mail sync progress depending on your app's needs.
78
+ If you're using the open-source version of the Nilas Sync Engine or have fewer than 10 accounts associated with your developer app, you don't need to worry about billing. However, if you've requested production access to the Sync Engine, you are billed monthly based on the number of email accounts you've connected to Inbox. You can choose to start accounts in "trial" state and sync slowly at a rate of one message per minute so users can try out your app. If you use trial mode, you need to upgrade accounts (and start paying for them) within 30 days or they will automatically expire. You may wish to upgrade accounts earlier to dramatically speed up the mail sync progress depending on your app's needs.
79
79
 
80
80
  **Starting an Account in Trial Mode**
81
81
 
82
- When you're redirecting the user to Inbox to authenticate with their email provider,
82
+ When you're redirecting the user to Nilas to authenticate with their email provider,
83
83
  pass the additional `trial: true` option to start their account in trial mode.
84
84
 
85
85
  ```ruby
@@ -89,17 +89,17 @@ pass the additional `trial: true` option to start their account in trial mode.
89
89
  **Upgrading an Account**
90
90
 
91
91
  ```ruby
92
- # Initialize an Inbox object with your app ID and secret, and the API token
93
- # for the user account you'd like to upgrade.
94
- inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, inbox_token)
95
- inbox.upgrade_account!
92
+ inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, nil)
93
+ account = inbox.accounts.find(account_id)
94
+ account.upgrade!
96
95
  ```
97
96
 
98
97
  **Cancelling an Account**
99
98
 
100
99
  ```ruby
101
- inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, inbox_token)
102
- inbox.downgrade_account!
100
+ inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, nil)
101
+ account = inbox.accounts.find(account_id)
102
+ account.downgrade!
103
103
 
104
104
  # Your Inbox API token will be revoked, you will not be charged
105
105
  ```
@@ -110,7 +110,7 @@ pass the additional `trial: true` option to start their account in trial mode.
110
110
  # Query the status of every account linked to the app
111
111
  inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, inbox_token)
112
112
  accounts = inbox.accounts
113
- accounts.map { |a| [a.account_id, a.sync_state] } # Available fields are: account_id, sync_state, trial and trial_expires. See lib/account.rb for more details.
113
+ accounts.each { |a| [a.account_id, a.sync_state] } # Available fields are: account_id, sync_state, trial, trial_expires, billing_state and namespace_id. See lib/account.rb for more details.
114
114
  ```
115
115
 
116
116
  ### Fetching Namespaces
@@ -140,21 +140,27 @@ thread = namespace.threads.find('ac123acd123ef123')
140
140
  # (paginating 50 at a time until no more are returned.)
141
141
  namespace.threads.where(:tag => 'inbox').each do |thread|
142
142
  puts thread.subject
143
- end
143
+ end
144
144
 
145
145
  # List the 5 most recent unread threads
146
146
  namespace.threads.where(:tag => 'unread').range(0,4).each do |thread|
147
147
  puts thread.subject
148
- end
148
+ end
149
149
 
150
- # List all threads with 'ben@inboxapp.com'
151
- namespace.threads.where(:any_email => 'ben@inboxapp.com').each do |thread|
150
+ # List all threads with 'ben@nilas.com'
151
+ namespace.threads.where(:any_email => 'ben@nilas.com').each do |thread|
152
152
  puts thread.subject
153
- end
153
+ end
154
154
 
155
- # Collect all threads with 'ben@inboxapp.com' into an array.
155
+ # Get number of all threads
156
+ count = namespace.threads.count
157
+
158
+ # Get number of threads with 'ben@inboxapp.com'
159
+ count = namespace.threads.where(:any_email => 'ben@inboxapp.com').count
160
+
161
+ # Collect all threads with 'ben@nilas.com' into an array.
156
162
  # Note: for large numbers of threads, this is not advised.
157
- threads = namespace.threads.where(:any_email => 'ben@inboxapp.com').all
163
+ threads = namespace.threads.where(:any_email => 'ben@nilas.com').all
158
164
  ```
159
165
 
160
166
 
@@ -202,10 +208,10 @@ file.save!
202
208
  Each of the primary collections (contacts, messages, etc.) behave the same way as `threads`. For example, finding messages with a filter is similar to finding threads:
203
209
 
204
210
  ```ruby
205
- messages = namespace.messages.where(:to => 'ben@inboxapp.com`).all
211
+ messages = namespace.messages.where(:to => 'ben@nilas.com`).all
206
212
  ```
207
213
 
208
- The `where` method accepts a hash of filters, as documented in the [Inbox Filters Documentation](https://www.inboxapp.com/docs/api#filters).
214
+ The `where` method accepts a hash of filters, as documented in the [Inbox Filters Documentation](https://www.nilas.com/docs/api#filters).
209
215
 
210
216
  ### Getting the raw contents of a message
211
217
 
@@ -221,13 +227,13 @@ raw_contents = message.raw.rfc2822
221
227
  ```ruby
222
228
  # Create a new draft
223
229
  draft = namespace.drafts.build(
224
- :to => [{:name => 'Ben Gotow', :email => 'ben@inboxapp.com'}],
230
+ :to => [{:name => 'Ben Gotow', :email => 'ben@nilas.com'}],
225
231
  :subject => "Sent by Ruby",
226
232
  :body => "Hi there!<strong>This is HTML</strong>"
227
233
  )
228
234
 
229
235
  # Modify attributes as necessary
230
- draft.cc = [{:name => 'Michael', :email => 'mg@inboxapp.com'}]
236
+ draft.cc = [{:name => 'Michael', :email => 'mg@nilas.com'}]
231
237
 
232
238
  # Add the file we uploaded as an attachment
233
239
  draft.attach(file)
@@ -235,8 +241,7 @@ draft.attach(file)
235
241
  # Save the draft
236
242
  draft.save!
237
243
 
238
- # Send the draft. This method returns immediately and queues the message
239
- # with Inbox for delivery through the user's SMTP gateway.
244
+ # Send the draft.
240
245
  draft.send!
241
246
  ```
242
247
 
@@ -257,9 +262,29 @@ new_event.when = {:start_time => 1407542195, :end_time => 1407543195}
257
262
  new_event.save!
258
263
  ```
259
264
 
265
+ ### Handling Errors
266
+ The Nilas API uses conventional HTTP response codes to indicate success or failure of an API request. The ruby gem raises these as native exceptions.
267
+
268
+ Code | Error Type | Description
269
+ --- | --- | ---
270
+ 400 | InvalidRequest | Your request has invalid parameters.
271
+ 403 | AccessDenied | You don't have authorization to access the requested resource or perform the requested action. You may need to re-authenticate the user.
272
+ 404 | ResourceNotFound | The requested resource doesn't exist.
273
+ 500 | APIError | There was an internal error with the Nilas server.
274
+
275
+ A few additional exceptions are raised by the `draft.send!` method if your draft couldn't be sent.
276
+
277
+ Code | Error Type | Description
278
+ --- | --- | ---
279
+ 402 | MessageRejected| The message was syntactically valid, but rejected for delivery by the mail server.
280
+ 429 | SendingQuotaExceeded | The user has exceeded their daily sending quota.
281
+ 503 | ServiceUnavailable | There was a temporary error establishing a connection to the user's mail server.
282
+
283
+
284
+
260
285
  ## Open-Source Sync Engine
261
286
 
262
- The [Inbox Sync Engine](http://github.com/inboxapp/inbox) is open-source, and you can also use the Ruby gem with the open-source API. Since the open-source API provides no authentication or security, connecting to it is simple. When you instantiate the Inbox object, provide nil for the App ID, App Secret, and API Token, and pass the fully-qualified address to your copy of the sync engine:
287
+ The [Nilas Sync Engine](http://github.com/inboxapp/inbox) is open-source, and you can also use the Ruby gem with the open-source API. Since the open-source API provides no authentication or security, connecting to it is simple. When you instantiate the Inbox object, provide `nil` for the App ID, App Secret, and API Token, and pass the fully-qualified address to your copy of the sync engine:
263
288
 
264
289
  ```ruby
265
290
  require 'inbox'
@@ -269,24 +294,23 @@ inbox = Inbox::API.new(nil, nil, nil, 'http://localhost:5555/')
269
294
 
270
295
  ## Contributing
271
296
 
272
- We'd love your help making the Inbox ruby gem better. Join the Google Group for project updates and feature discussion. We also hang out in `##inbox` on [irc.freenode.net](http://irc.freenode.net), or you can email [help@inboxapp.com](mailto:help@inboxapp.com).
297
+ We'd love your help making the Nilas ruby gem better. Join the Google Group for project updates and feature discussion. We also hang out in `#nilas` on [irc.freenode.net](http://irc.freenode.net), or you can email [support@nilas.com](mailto:support@nilas.com).
273
298
 
274
- Please sign the Contributor License Agreement before submitting pull requests. (It's similar to other projects, like NodeJS or Meteor.)
299
+ Please sign the [Contributor License Agreement](https://www.nilas.com/cla.html) before submitting pull requests. (It's similar to other projects, like NodeJS or Meteor.)
275
300
 
276
301
  Tests can be run with:
277
302
 
278
303
  rspec spec
279
304
 
280
305
 
281
- ## Deployment
306
+ ## Deployment
282
307
 
283
- The Inbox ruby gem uses [Jeweler](https://github.com/technicalpickles/jeweler) for release management. Jeweler should be installed automatically when you call `bundle`, and extends `rake` to include a few more commands. When you're ready to release a new version, do something like this:
308
+ The Nilas ruby gem uses [Jeweler](https://github.com/technicalpickles/jeweler) for release management. Jeweler should be installed automatically when you call `bundle`, and extends `rake` to include a few more commands. When you're ready to release a new version, edit `lib/version.rb` and then build:
284
309
 
285
- rake version:bump:minor (or :major or :patch)
286
310
  rake build
287
311
 
288
312
  Test your new version (found in `pkg/`) locally, and then release with:
289
313
 
290
314
  rake release
291
315
 
292
- If it's your first time updating the ruby gem, you may be prompted for the username/password for rubygems.org. Members of the Inbox team can find that by doing `fetch-password rubygems`.
316
+ If it's your first time updating the ruby gem, you may be prompted for the username/password for rubygems.org. Members of the Nilas team can find that by doing `fetch-password rubygems`.
data/lib/account.rb CHANGED
@@ -3,17 +3,30 @@ require 'restful_model'
3
3
  module Inbox
4
4
  class Account < RestfulModel
5
5
 
6
- attr_accessor :account_id
7
- attr_accessor :trial
8
- attr_accessor :trial_expires
9
- attr_accessor :sync_state
10
-
11
- def initialize(params = {})
12
- @account_id = params.fetch(:account_id, '')
13
- @trial = params.fetch(:trial, '')
14
- @trial_expires = params.fetch(:trial_expires, '')
15
- @sync_state = params.fetch(:sync_state, '')
6
+ parameter :account_id
7
+ parameter :trial
8
+ parameter :trial_expires
9
+ parameter :sync_state
10
+ parameter :billing_state
11
+
12
+ def _perform_account_action!(action)
13
+ raise UnexpectedAccountAction.new unless action == "upgrade" || action == "downgrade"
14
+
15
+ collection = ManagementModelCollection.new(Account, @_api, @namespace_id, {:account_id=>@account_id})
16
+ ::RestClient.post("#{collection.url}/#{@account_id}/#{action}",{}) do |response, request, result|
17
+ # Throw any exceptions
18
+ json = Inbox.interpret_response(result, response, :expected_class => Object)
19
+ end
20
+ end
21
+
22
+ def upgrade!
23
+ _perform_account_action!('upgrade')
16
24
  end
17
25
 
26
+ def downgrade!
27
+ _perform_account_action!('downgrade')
28
+ end
29
+
30
+
18
31
  end
19
32
  end
data/lib/draft.rb CHANGED
@@ -5,7 +5,6 @@ module Inbox
5
5
 
6
6
  parameter :thread_id
7
7
  parameter :version
8
- parameter :state
9
8
 
10
9
  def attach(file)
11
10
  file.save! unless file.id
data/lib/inbox.rb CHANGED
@@ -19,16 +19,38 @@ module Inbox
19
19
  self.error_type = type
20
20
  end
21
21
  end
22
+ class InvalidRequest < APIError; end
23
+ class MessageRejected < APIError; end
24
+ class SendingQuotaExceeded < APIError; end
25
+ class ServiceUnavailable < APIError; end
22
26
 
23
- def self.interpret_response(result, result_content, options = {})
27
+ def self.interpret_http_status(result)
24
28
  # Handle HTTP errors and RestClient errors
25
29
  raise ResourceNotFound.new if result.code.to_i == 404
26
30
  raise AccessDenied.new if result.code.to_i == 403
31
+ end
32
+
33
+ def self.interpret_response(result, result_content, options = {})
34
+ # Handle HTTP errors
35
+ Inbox.interpret_http_status(result)
27
36
 
28
37
  # Handle content expectation errors
29
38
  raise UnexpectedResponse.new if options[:expected_class] && result_content.empty?
30
39
  json = JSON.parse(result_content)
31
- raise APIError.new(json['type'], json['message']) if json.is_a?(Hash) && json['type'] == 'api_error'
40
+ if json.is_a?(Hash) && (json['type'] == 'api_error' or json['type'] == 'invalid_request_error')
41
+ if result.code.to_i == 400
42
+ exc = InvalidRequest
43
+ elsif result.code.to_i == 402
44
+ exc = MessageRejected
45
+ elsif result.code.to_i == 429
46
+ exc = SendingQuotaExceeded
47
+ elsif result.code.to_i == 503
48
+ exc = ServiceUnavailable
49
+ else
50
+ exc = APIError
51
+ end
52
+ raise exc.new(json['type'], json['message'])
53
+ end
32
54
  raise UnexpectedResponse.new(result.msg) if result.is_a?(Net::HTTPClientError)
33
55
  raise UnexpectedResponse.new if options[:expected_class] && !json.is_a?(options[:expected_class])
34
56
  json
@@ -45,16 +67,20 @@ module Inbox
45
67
  attr_reader :app_id
46
68
  attr_reader :app_secret
47
69
 
48
- def initialize(app_id, app_secret, access_token = nil, api_server = 'https://api.inboxapp.com')
70
+ def initialize(app_id, app_secret, access_token = nil, api_server = 'https://api.nilas.com',
71
+ service_domain = 'www.nilas.com')
49
72
  raise "When overriding the Inbox API server address, you must include https://" unless api_server.include?('://')
50
73
  @api_server = api_server
51
74
  @access_token = access_token
52
75
  @app_secret = app_secret
53
76
  @app_id = app_id
77
+ @service_domain = service_domain
78
+ @version = Inbox::VERSION
54
79
 
55
80
  if ::RestClient.before_execution_procs.empty?
56
81
  ::RestClient.add_before_execution_proc do |req, params|
57
82
  req.add_field('X-Inbox-API-Wrapper', 'ruby')
83
+ req['User-Agent'] = "Ruby SDK #{@version}"
58
84
  end
59
85
  end
60
86
  end
@@ -70,7 +96,12 @@ module Inbox
70
96
  if options[:trial] == true
71
97
  trialString = 'true'
72
98
  end
73
- "https://www.inboxapp.com/oauth/authorize?client_id=#{@app_id}&trial=#{trialString}&response_type=code&scope=email&login_hint=#{login_hint}&redirect_uri=#{redirect_uri}"
99
+ "https://#{@service_domain}/oauth/authorize?client_id=#{@app_id}&trial=#{trialString}&response_type=code&scope=email&login_hint=#{login_hint}&redirect_uri=#{redirect_uri}"
100
+ end
101
+
102
+ def url_for_management
103
+ protocol, domain = @api_server.split('//')
104
+ accounts_path = "#{protocol}//#{@app_secret}:@#{domain}/a/#{@app_id}/accounts"
74
105
  end
75
106
 
76
107
  def set_access_token(token)
@@ -85,7 +116,7 @@ module Inbox
85
116
  'code' => code
86
117
  }
87
118
 
88
- ::RestClient.get("https://www.inboxapp.com/oauth/token", {:params => data}) do |response, request, result|
119
+ ::RestClient.get("https://#{@service_domain}/oauth/token", {:params => data}) do |response, request, result|
89
120
  json = Inbox.interpret_response(result, response, :expected_class => Object)
90
121
  return json['access_token']
91
122
  end
@@ -100,40 +131,9 @@ module Inbox
100
131
 
101
132
  # Billing Methods
102
133
 
103
- def _perform_account_action!(action)
104
- raise UnexpectedAccountAction.new unless action == "upgrade" || action == "downgrade"
105
-
106
- protocol, domain = @api_server.split('//')
107
- account_ids = namespaces.all.collect {|n| n.account_id }.uniq
108
- account_ids.each do | id |
109
- ::RestClient.post("#{protocol}//#{@app_secret}:@#{domain}/a/#{@app_id}/accounts/#{id}/#{action}",{}) do |response, request, result|
110
- # Throw any exceptions
111
- json = Inbox.interpret_response(result, response, :expected_class => Object)
112
- end
113
- end
114
- end
115
-
116
- def upgrade_account!
117
- _perform_account_action!('upgrade')
118
- end
119
-
120
- def downgrade_account!
121
- _perform_account_action!('downgrade')
122
- end
123
-
124
134
  def accounts
125
- protocol, domain = @api_server.split('//')
126
- accounts_path = "#{protocol}//#{@app_secret}:@#{domain}/a/#{@app_id}/accounts/"
127
-
128
- RestClient.get(accounts_path) do |response, request, result|
129
- json = Inbox.interpret_response(result, response, :expected_class => Object)
130
- return json.map do |account_json|
131
- Account.new({ :account_id => account_json.fetch('account_id', ''),
132
- :trial => account_json.fetch('trial', ''),
133
- :trial_expires => account_json.fetch('trial_expires', nil),
134
- :sync_state => account_json.fetch('sync_state', '')})
135
- end
136
- end
135
+ @accounts ||= ManagementModelCollection.new(Account, self, nil)
136
+ @accounts
137
137
  end
138
138
  end
139
139
  end
data/lib/restful_model.rb CHANGED
@@ -70,8 +70,10 @@ module Inbox
70
70
  end
71
71
 
72
72
  def destroy
73
- update('DELETE', '')
73
+ ::RestClient.send('delete', self.url) do |response, request|
74
+ Inbox.interpret_http_status(response)
75
+ end
74
76
  end
75
77
 
76
78
  end
77
- end
79
+ end
@@ -27,6 +27,13 @@ module Inbox
27
27
  end
28
28
  end
29
29
 
30
+ def count
31
+ RestClient.get(url, params: @filters.merge(view: 'count')) { |response,request,result|
32
+ json = Inbox.interpret_response(result, response)
33
+ return json['count']
34
+ }
35
+ end
36
+
30
37
  def first
31
38
  get_model_collection.first
32
39
  end
@@ -71,7 +78,7 @@ module Inbox
71
78
 
72
79
  def build(args)
73
80
  for key in args.keys
74
- args[key.to_s] = args[key]
81
+ args[key.to_s] = args[key]
75
82
  end
76
83
  model = @model_class.new(@_api, @namespace_id)
77
84
  model.inflate(args)
@@ -130,4 +137,13 @@ module Inbox
130
137
  end
131
138
 
132
139
  end
140
+
141
+ # a ManagementModelCollection is similar to a RestfulModelCollection except
142
+ # it's used by models under the /a/<app_id> namespace (mostly account status
143
+ # and billing methods).
144
+ class ManagementModelCollection < RestfulModelCollection
145
+ def url
146
+ @_api.url_for_management
147
+ end
148
+ end
133
149
  end
@@ -3,7 +3,9 @@ module Inbox
3
3
  def time_attr_accessor(attr)
4
4
  parameter attr
5
5
  define_method "#{attr}=" do |value|
6
- instance_variable_set "@#{attr}", Time.at(value).utc
6
+ if value
7
+ instance_variable_set "@#{attr}", Time.at(value).utc
8
+ end
7
9
  end
8
10
  end
9
11
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Inbox
2
- VERSION = "0.3.0"
2
+ VERSION = "0.14.0"
3
3
  end
metadata CHANGED
@@ -1,165 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Gotow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: shoulda
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.12'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.12'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.3.5
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.3.5
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: jeweler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.8.4
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.8.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry-nav
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry-stack_explorer
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: webmock
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  description: 'Gem for interacting with the Inbox API that allows you to create and
154
154
  publish one-page websites, subscribe to web hooks and receive events when those
155
155
  pages are interacted with. Visit http://www.populr.me/ for more information. '
156
- email: ben@inboxapp.com
156
+ email: ben@nilas.com
157
157
  executables: []
158
158
  extensions: []
159
159
  extra_rdoc_files:
160
160
  - LICENSE.txt
161
161
  - README.md
162
162
  files:
163
+ - LICENSE.txt
164
+ - README.md
163
165
  - lib/account.rb
164
166
  - lib/calendar.rb
165
167
  - lib/contact.rb
@@ -177,8 +179,6 @@ files:
177
179
  - lib/thread.rb
178
180
  - lib/time_attr_accessor.rb
179
181
  - lib/version.rb
180
- - LICENSE.txt
181
- - README.md
182
182
  homepage: http://github.com/inboxapp/inbox-ruby
183
183
  licenses:
184
184
  - MIT
@@ -189,17 +189,17 @@ require_paths:
189
189
  - lib
190
190
  required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - '>='
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.0.14
202
+ rubygems_version: 2.2.2
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Gem for interacting with the Inbox API