inbox 0.15.2 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -23
- data/lib/draft.rb +1 -0
- data/lib/inbox.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf030496c5f6b9094c940e493bbf2c5a8e2e129
|
4
|
+
data.tar.gz: 3f73ef1b40d9d68478fd5c4cfcbcaff7899bb970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46e6ae83107fce52d5cf67eff7f606128ebb4004bf05bb9968e0ba4149086efa41be3b34e2bf3c3194145b2e51d83d7d031f35166c4fb0b22df7dd9e25fdffb0
|
7
|
+
data.tar.gz: 2fa3a371f11cd85d71098b7d4c438db406dbc44fc7df435852f47953e435187f7b56417379da14fd8e9f5a25642c6d42ec446384e0d22bd115ce836c82a9a27f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Nyƒlas REST API Ruby bindings
|
2
2
|
|
3
3
|
## Installation
|
4
4
|
|
@@ -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
|
39
|
+
Before you can interact with the Inbox API, you need to register for the Nylas Developer Program at [https://www.nylas.com/](https://www.nylas.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
|
46
|
+
The Nylas 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 Nylas, visit the [Developer Documentation](https://www.nylas.com/docs/knowledgebase#authentication).
|
47
47
|
|
48
|
-
**Step 1: Redirect the user to
|
48
|
+
**Step 1: Redirect the user to Nylas:**
|
49
49
|
|
50
50
|
```ruby
|
51
51
|
require 'inbox'
|
@@ -53,7 +53,7 @@ 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@
|
56
|
+
user_email = 'ben@nylas.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')
|
@@ -75,11 +75,11 @@ end
|
|
75
75
|
|
76
76
|
### Managing Billing
|
77
77
|
|
78
|
-
If you're using the open-source version of the
|
78
|
+
If you're using the open-source version of the Nylas 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
|
82
|
+
When you're redirecting the user to Nylas 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
|
@@ -147,8 +147,8 @@ namespace.threads.where(:tag => 'unread').range(0,4).each do |thread|
|
|
147
147
|
puts thread.subject
|
148
148
|
end
|
149
149
|
|
150
|
-
# List all threads with 'ben@
|
151
|
-
namespace.threads.where(:any_email => 'ben@
|
150
|
+
# List all threads with 'ben@nylas.com'
|
151
|
+
namespace.threads.where(:any_email => 'ben@nylas.com').each do |thread|
|
152
152
|
puts thread.subject
|
153
153
|
end
|
154
154
|
|
@@ -158,9 +158,9 @@ count = namespace.threads.count
|
|
158
158
|
# Get number of threads with 'ben@inboxapp.com'
|
159
159
|
count = namespace.threads.where(:any_email => 'ben@inboxapp.com').count
|
160
160
|
|
161
|
-
# Collect all threads with 'ben@
|
161
|
+
# Collect all threads with 'ben@nylas.com' into an array.
|
162
162
|
# Note: for large numbers of threads, this is not advised.
|
163
|
-
threads = namespace.threads.where(:any_email => 'ben@
|
163
|
+
threads = namespace.threads.where(:any_email => 'ben@nylas.com').all
|
164
164
|
```
|
165
165
|
|
166
166
|
|
@@ -208,10 +208,10 @@ file.save!
|
|
208
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:
|
209
209
|
|
210
210
|
```ruby
|
211
|
-
messages = namespace.messages.where(:to => 'ben@
|
211
|
+
messages = namespace.messages.where(:to => 'ben@nylas.com`).all
|
212
212
|
```
|
213
213
|
|
214
|
-
The `where` method accepts a hash of filters, as documented in the [Inbox Filters Documentation](https://www.
|
214
|
+
The `where` method accepts a hash of filters, as documented in the [Inbox Filters Documentation](https://www.nylas.com/docs/api#filters).
|
215
215
|
|
216
216
|
### Getting the raw contents of a message
|
217
217
|
|
@@ -227,13 +227,13 @@ raw_contents = message.raw.rfc2822
|
|
227
227
|
```ruby
|
228
228
|
# Create a new draft
|
229
229
|
draft = namespace.drafts.build(
|
230
|
-
:to => [{:name => 'Ben Gotow', :email => 'ben@
|
230
|
+
:to => [{:name => 'Ben Gotow', :email => 'ben@nylas.com'}],
|
231
231
|
:subject => "Sent by Ruby",
|
232
232
|
:body => "Hi there!<strong>This is HTML</strong>"
|
233
233
|
)
|
234
234
|
|
235
235
|
# Modify attributes as necessary
|
236
|
-
draft.cc = [{:name => 'Michael', :email => 'mg@
|
236
|
+
draft.cc = [{:name => 'Michael', :email => 'mg@nylas.com'}]
|
237
237
|
|
238
238
|
# Add the file we uploaded as an attachment
|
239
239
|
draft.attach(file)
|
@@ -264,7 +264,7 @@ new_event.save!
|
|
264
264
|
|
265
265
|
## Using the Delta sync API
|
266
266
|
|
267
|
-
The delta sync API allows fetching all the changes that occured since a specified time. [Read this](https://
|
267
|
+
The delta sync API allows fetching all the changes that occured since a specified time. [Read this](https://nylas.com/docs/api#sync-protocol) for more details about the API.
|
268
268
|
|
269
269
|
````ruby
|
270
270
|
# Get all the messages starting from timestamp
|
@@ -310,14 +310,14 @@ end
|
|
310
310
|
|
311
311
|
|
312
312
|
### Handling Errors
|
313
|
-
The
|
313
|
+
The Nylas API uses conventional HTTP response codes to indicate success or failure of an API request. The ruby gem raises these as native exceptions.
|
314
314
|
|
315
315
|
Code | Error Type | Description
|
316
316
|
--- | --- | ---
|
317
317
|
400 | InvalidRequest | Your request has invalid parameters.
|
318
318
|
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.
|
319
319
|
404 | ResourceNotFound | The requested resource doesn't exist.
|
320
|
-
500 | APIError | There was an internal error with the
|
320
|
+
500 | APIError | There was an internal error with the Nylas server.
|
321
321
|
|
322
322
|
A few additional exceptions are raised by the `draft.send!` method if your draft couldn't be sent.
|
323
323
|
|
@@ -331,7 +331,7 @@ Code | Error Type | Description
|
|
331
331
|
|
332
332
|
## Open-Source Sync Engine
|
333
333
|
|
334
|
-
The [
|
334
|
+
The [Nylas 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:
|
335
335
|
|
336
336
|
```ruby
|
337
337
|
require 'inbox'
|
@@ -341,9 +341,9 @@ inbox = Inbox::API.new(nil, nil, nil, 'http://localhost:5555/')
|
|
341
341
|
|
342
342
|
## Contributing
|
343
343
|
|
344
|
-
We'd love your help making the
|
344
|
+
We'd love your help making the Nylas ruby gem better. Join the Google Group for project updates and feature discussion. We also hang out in `#Nylas` on [irc.freenode.net](http://irc.freenode.net), or you can email [support@nylas.com](mailto:support@nylas.com).
|
345
345
|
|
346
|
-
Please sign the [Contributor License Agreement](https://www.
|
346
|
+
Please sign the [Contributor License Agreement](https://www.nylas.com/cla.html) before submitting pull requests. (It's similar to other projects, like NodeJS or Meteor.)
|
347
347
|
|
348
348
|
Tests can be run with:
|
349
349
|
|
@@ -352,7 +352,7 @@ Tests can be run with:
|
|
352
352
|
|
353
353
|
## Deployment
|
354
354
|
|
355
|
-
The
|
355
|
+
The Nylas 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:
|
356
356
|
|
357
357
|
rake build
|
358
358
|
|
@@ -360,4 +360,4 @@ Test your new version (found in `pkg/`) locally, and then release with:
|
|
360
360
|
|
361
361
|
rake release
|
362
362
|
|
363
|
-
If it's your first time updating the ruby gem, you may be prompted for the username/password for rubygems.org. Members of the
|
363
|
+
If it's your first time updating the ruby gem, you may be prompted for the username/password for rubygems.org. Members of the Nylas team can find that by doing `fetch-password rubygems`.
|
data/lib/draft.rb
CHANGED
data/lib/inbox.rb
CHANGED
@@ -67,8 +67,8 @@ module Inbox
|
|
67
67
|
attr_reader :app_id
|
68
68
|
attr_reader :app_secret
|
69
69
|
|
70
|
-
def initialize(app_id, app_secret, access_token = nil, api_server = 'https://api.
|
71
|
-
service_domain = 'www.
|
70
|
+
def initialize(app_id, app_secret, access_token = nil, api_server = 'https://api.nylas.com',
|
71
|
+
service_domain = 'www.nylas.com')
|
72
72
|
raise "When overriding the Inbox API server address, you must include https://" unless api_server.include?('://')
|
73
73
|
@api_server = api_server
|
74
74
|
@access_token = access_token
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.3
|
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-
|
11
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -153,7 +153,7 @@ dependencies:
|
|
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@
|
156
|
+
email: ben@nylas.com
|
157
157
|
executables: []
|
158
158
|
extensions: []
|
159
159
|
extra_rdoc_files:
|
@@ -179,7 +179,7 @@ files:
|
|
179
179
|
- lib/thread.rb
|
180
180
|
- lib/time_attr_accessor.rb
|
181
181
|
- lib/version.rb
|
182
|
-
homepage: http://github.com/
|
182
|
+
homepage: http://github.com/nylas/inbox-ruby
|
183
183
|
licenses:
|
184
184
|
- MIT
|
185
185
|
metadata: {}
|