inbox 0.4.4 → 0.5.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: 9f4cbfbc683a96da2de69ace4b9ef8e10c975647
4
- data.tar.gz: 9ec4ea5c67d021354c7f6c979a9fd94f270832dc
3
+ metadata.gz: b3683088737138e49adc1b3e020a5ab888bb5c9f
4
+ data.tar.gz: fbd77affbf2fb71f2ca13f6210f4b3820b8a53b1
5
5
  SHA512:
6
- metadata.gz: 94b28a6674f623198da516bcbc27a2a57721640ef565108a4b6364ac666ca00c5cb88e075e823eb676a63fce73187749e5ee47c1a10b1676ef56b7a475e98023
7
- data.tar.gz: 78e0263b832980ee54a282f5174336bedc7b2bc7c869f5fb7bfd3fa39dd44dd22b22f4875f5f1c2edcf6edb1c7012b3e38d154e37b694e449d09f11d5dad702e
6
+ metadata.gz: ffa62812e0ecbe58e37d3d56b027b3362cbb57b08e15f42365f6b56e4fe266b5d8fbec65110b383ccade3bacd07cf07454dbcd90ee0957f0963c29abcdb637aa
7
+ data.tar.gz: 0dde7e743a57e13c65fba44fb77024e5d178713e6abf129eeca2c97415059b2976b15ec3f3722bf8eb2ff6bb409dda31d8bf422e5e14a7cfe5800d6e6899e441
data/README.md CHANGED
@@ -73,6 +73,28 @@ def login_callback
73
73
  end
74
74
  ```
75
75
 
76
+ ### Managing Billing
77
+
78
+ If you're using the open-source version of the Inbox API or have fewer than 100 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. Accounts initially start in a "trial" state and sync slowly at a rate of one message per minute so users can try out your app. After 30 days, you need to upgrade accounts (and start paying for them) 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
+
80
+ **Upgrading an Account**
81
+
82
+ ```ruby
83
+ # Initialize an Inbox object with your app ID and secret, and the API token
84
+ # for the user account you'd like to upgrade.
85
+ inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, inbox_token)
86
+ inbox.upgrade_account!
87
+ ```
88
+
89
+ **Cancelling an Account**
90
+
91
+ ```ruby
92
+ inbox = Inbox::API.new(config.inbox_app_id, config.inbox_app_secret, inbox_token)
93
+ inbox.downgrade_account!
94
+
95
+ # Your Inbox API token will be revoked, you will not be charged
96
+ ```
97
+
76
98
  ### Fetching Namespaces
77
99
 
78
100
  ```ruby
data/lib/inbox.rb CHANGED
@@ -9,6 +9,7 @@ module Inbox
9
9
  class AccessDenied < StandardError; end
10
10
  class ResourceNotFound < StandardError; end
11
11
  class NoAuthToken < StandardError; end
12
+ class UnexpectedAccountAction < StandardError; end
12
13
  class UnexpectedResponse < StandardError; end
13
14
  class APIError < StandardError
14
15
  attr_accessor :error_type
@@ -90,6 +91,28 @@ module Inbox
90
91
  @namespaces
91
92
  end
92
93
 
93
- end
94
+ # Billing Methods
95
+
96
+ def _perform_account_action!(action)
97
+ raise UnexpectedAccountAction.new unless action == "upgrade" || action == "downgrade"
98
+
99
+ protocol, domain = @api_server.split('//')
100
+ account_ids = namespaces.all.collect {|n| n.account_id }.uniq
101
+ account_ids.each do | id |
102
+ ::RestClient.post("#{protocol}//#{@app_secret}:@#{domain}/a/#{@app_id}/accounts/#{id}/#{action}",{}) do |response, request, result|
103
+ # Throw any exceptions
104
+ json = Inbox.interpret_response(result, response, :expected_class => Object)
105
+ end
106
+ end
107
+ end
94
108
 
109
+ def upgrade_account!
110
+ _perform_account_action!('upgrade')
111
+ end
112
+
113
+ def downgrade_account!
114
+ _perform_account_action!('downgrade')
115
+ end
116
+
117
+ end
95
118
  end
data/lib/message.rb CHANGED
@@ -5,6 +5,7 @@ module Inbox
5
5
  class Message < RestfulModel
6
6
 
7
7
  attr_accessor :subject
8
+ attr_accessor :snippet
8
9
  attr_accessor :from
9
10
  attr_accessor :to
10
11
  attr_accessor :cc
data/lib/namespace.rb CHANGED
@@ -17,9 +17,9 @@ module Inbox
17
17
 
18
18
  class Namespace < RestfulModel
19
19
 
20
+ attr_accessor :account_id
20
21
  attr_accessor :email_address
21
22
  attr_accessor :provider
22
- attr_accessor :account
23
23
 
24
24
  def self.collection_name
25
25
  "n"
@@ -15,7 +15,7 @@ module Inbox
15
15
 
16
16
  def each
17
17
  offset = 0
18
- chunk_size = 50
18
+ chunk_size = 1000
19
19
  finished = false
20
20
  while (!finished) do
21
21
  results = get_model_collection(offset, chunk_size)
@@ -42,10 +42,10 @@ module Inbox
42
42
  collection
43
43
  end
44
44
 
45
- def range(offset = 0, limit = 50)
45
+ def range(offset = 0, limit = 1000)
46
46
  accumulated = []
47
47
  finished = false
48
- chunk_size = 50
48
+ chunk_size = 1000
49
49
 
50
50
  while (!finished && accumulated.length < limit) do
51
51
  results = get_model_collection(offset + accumulated.length, chunk_size)
@@ -116,7 +116,7 @@ module Inbox
116
116
  model
117
117
  end
118
118
 
119
- def get_model_collection(offset = 0, limit = 50)
119
+ def get_model_collection(offset = 0, limit = 1000)
120
120
  filters = @filters.clone
121
121
  filters[:offset] = offset
122
122
  filters[:limit] = limit
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.4.4
4
+ version: 0.5.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: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client