printreleaf 1.0.3 → 1.3.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: 31473a5421bed8c80fb386437d87d08f5f906b70
4
- data.tar.gz: 05df26f63a70efdd9d4172aee42269f1e89d00d0
3
+ metadata.gz: ce4ddb5134037b5e6e8ef6b72cb3d04246496db5
4
+ data.tar.gz: c08337cccecfa720e7494f6d909764d59e99d91d
5
5
  SHA512:
6
- metadata.gz: 241bdcde4a8f97a07a6552bb581d501b2c9b3a1643254219d82759586a819954b3146765c546c0e42932e12725692badc123c97300126222415b8a15343cdb5a
7
- data.tar.gz: a75e0ddfc79c67aa7765583918126a053eb6cbccc1c695dd37875081e1461e7740fb5509bc9e32c1cf2386f8c6865e937dea93d133625eef0b824a32bf9f6045
6
+ metadata.gz: 3568602fd62af9953a709e24348a4e35688757a9564be6700e3a35d0da455e30919bfd15b0cf529f916e84be9bc5ebc44c72de691e56882ef5fea46e3dce742b
7
+ data.tar.gz: 7aac996128d1c6a01add24bf0081b41009f8353c3442015c2efc6924b84b4bceb7424a3f469b6f572a29fabcd202157724f318a70517f82ccf7683dd0741c5ab
data/README.md CHANGED
@@ -54,11 +54,11 @@ account.users_count #=> 2
54
54
  account.mtd_pages #=> 1234
55
55
  account.qtd_pages #=> 12345
56
56
  account.ytd_pages #=> 123456
57
- account.lifetime_pages #=> 1234567
57
+ account.ltd_pages #=> 1234567
58
58
  account.mtd_trees #=> 0.15
59
59
  account.qtd_trees #=> 1.48
60
60
  account.ytd_trees #=> 14.82
61
- account.lifetime_trees #=> 148.1
61
+ account.ltd_trees #=> 148.1
62
62
  ```
63
63
 
64
64
  ### Listing Accounts
@@ -148,8 +148,8 @@ deposit = account.deposits.find("a86d591c-3c29-4bef-82c3-7a007fb6b19c") #=> #<Pr
148
148
  deposit.id #=> "a86d591c-3c29-4bef-82c3-7a007fb6b19c"
149
149
  deposit.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
150
150
  deposit.account #=> #<PrintReleaf::Account>
151
- deposit.source_id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
152
- deposit.source #=> #<PrintReleaf::Source>
151
+ deposit.feed_id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
152
+ deposit.feed #=> #<PrintReleaf::Feed>
153
153
  deposit.date #=> "2016-07-05T12:29:12Z"
154
154
  deposit.pages #=> 20000
155
155
  deposit.width #=> 0.2127
@@ -209,6 +209,64 @@ invitation.delete #=> true
209
209
  ```
210
210
 
211
211
 
212
+ ## Quotes
213
+
214
+ ### Listing Quotes
215
+
216
+ ```ruby
217
+ PrintReleaf::Quote.list #=> [#<PrintReleaf::Quote>, #<PrintReleaf::Quote>]
218
+ # -or-
219
+ account.quotes #=> [#<PrintReleaf::Quote>, #<PrintReleaf::Quote>]
220
+ ```
221
+
222
+ ### Retrieving a Quote
223
+
224
+ ```ruby
225
+ quote = PrintReleaf::Quote.find("83d12ee9-a187-489d-a93f-3096238f1f86") #=> #<PrintReleaf::Quote>
226
+ # -or-
227
+ quote = account.quotes.find("83d12ee9-a187-489d-a93f-3096238f1f86") #=> #<PrintReleaf::Quote>
228
+
229
+ quote.id #=> "83d12ee9-a187-489d-a93f-3096238f1f86"
230
+ quote.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
231
+ quote.created_at #=> "2015-10-22T01:52:12Z"
232
+ quote.account #=> #<PrintReleaf::Account>
233
+ quote.transaction_id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
234
+ quote.transaction #=> #<PrintReleaf::Transaction>
235
+ quote.trees #=> 63.048
236
+ quote.standard_pages #=> 525377
237
+ quote.msrp_rate #=> 0.0003
238
+ quote.msrp_price #=> 157.61
239
+ quote.items #=> [#<PrintReleaf::QuoteItem>, #<PrintReleaf::QuoteItem>]
240
+ ```
241
+
242
+ ### Creating a Quote
243
+
244
+ ```ruby
245
+ quote = PrintReleaf::Quote.create(
246
+ items: [
247
+ {
248
+ quantity: 20000,
249
+ width: 0.2127,
250
+ height: 0.2762,
251
+ paper_type_id: "a11c7abc-011e-462f-babb-3c6375fa6473"
252
+ },
253
+ {
254
+ quantity: 400000,
255
+ width: 0.2127,
256
+ height: 0.2762,
257
+ paper_type_id: "bbd0f271-2f9e-494c-b2af-7f9354b310ad"
258
+ }
259
+ ]
260
+ ) #=> #<PrintReleaf::Quote>
261
+ ```
262
+
263
+ ### Deleting a Quote
264
+
265
+ ```ruby
266
+ quote.delete #=> true
267
+ ```
268
+
269
+
212
270
  ## Servers
213
271
 
214
272
  ### Listing Servers
@@ -262,73 +320,73 @@ server.delete #=> true
262
320
  ```
263
321
 
264
322
 
265
- ## Sources
323
+ ## Feeds
266
324
 
267
- ### Listing Sources
325
+ ### Listing Feeds
268
326
 
269
327
  ```ruby
270
- PrintReleaf::Source.list #=> [#<PrintReleaf::Source>, #<PrintReleaf::Source>]
328
+ PrintReleaf::Feed.list #=> [#<PrintReleaf::Feed>, #<PrintReleaf::Feed>]
271
329
  # -or-
272
- account.sources #=> [#<PrintReleaf::Source>, #<PrintReleaf::Source>]
330
+ account.feeds #=> [#<PrintReleaf::Feed>, #<PrintReleaf::Feed>]
273
331
  ```
274
332
 
275
- ### Retrieving a Source
333
+ ### Retrieving a Feed
276
334
 
277
335
  ```ruby
278
- source = PrintReleaf::Source.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Source>
336
+ feed = PrintReleaf::Feed.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Feed>
279
337
  # -or-
280
- source = account.sources.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Source>
338
+ feed = account.feeds.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Feed>
281
339
 
282
- source.id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
283
- source.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
284
- source.account #=> #<PrintReleaf::Account>
285
- source.type #=> "fmaudit"
286
- source.server_id #=> "eadabb78-b199-43cb-adbd-ab36ce5c5a10"
287
- source.server #=> #<PrintReleaf::Server>
288
- source.external_id #=> "456"
289
- source.collection_scope #=> "managed_only"
290
- source.created_at #=> "2016-03-07T00:04:09Z"
291
- source.status #=> "active"
292
- source.activated_at #=> "2016-03-07T00:04:09Z"
293
- source.deactivated_at #=> nil
294
- source.health_check #=> "healthy"
295
- source.health_check_checked_at #=> "2017-03-07T00:04:09Z"
296
- source.health_check_changed_at #=> "2017-03-07T00:04:09Z"
340
+ feed.id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
341
+ feed.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
342
+ feed.account #=> #<PrintReleaf::Account>
343
+ feed.type #=> "fmaudit"
344
+ feed.server_id #=> "eadabb78-b199-43cb-adbd-ab36ce5c5a10"
345
+ feed.server #=> #<PrintReleaf::Server>
346
+ feed.external_id #=> "456"
347
+ feed.collection_scope #=> "managed_only"
348
+ feed.created_at #=> "2016-03-07T00:04:09Z"
349
+ feed.status #=> "active"
350
+ feed.activated_at #=> "2016-03-07T00:04:09Z"
351
+ feed.deactivated_at #=> nil
352
+ feed.health_check #=> "healthy"
353
+ feed.health_check_checked_at #=> "2017-03-07T00:04:09Z"
354
+ feed.health_check_changed_at #=> "2017-03-07T00:04:09Z"
297
355
  ```
298
356
 
299
- ### Creating a Source
357
+ ### Creating a Feed
300
358
 
301
359
  ```ruby
302
- source = PrintReleaf::Source.create(
360
+ feed = PrintReleaf::Feed.create(
303
361
  type: "printfleet",
304
362
  server_id: "9a6a1ced-4e71-4919-9d6d-25075834c404",
305
363
  external_id: "732ec0d3-20e3-439e-94e6-e64b40eb533a"
306
- ) #=> #<PrintReleaf::Source>
364
+ ) #=> #<PrintReleaf::Feed>
307
365
  ```
308
366
 
309
- ### Updating a Source
367
+ ### Updating a Feed
310
368
 
311
369
  ```ruby
312
- source.external_id = "abc123"
313
- source.save #=> true
370
+ feed.external_id = "abc123"
371
+ feed.save #=> true
314
372
  ```
315
373
 
316
- ### Activating a Source
374
+ ### Activating a Feed
317
375
 
318
376
  ```ruby
319
- source.activate #=> true
377
+ feed.activate #=> true
320
378
  ```
321
379
 
322
- ### Deactivating a Source
380
+ ### Deactivating a Feed
323
381
 
324
382
  ```ruby
325
- source.deactivate #=> true
383
+ feed.deactivate #=> true
326
384
  ```
327
385
 
328
- ### Deleting a Source
386
+ ### Deleting a Feed
329
387
 
330
388
  ```ruby
331
- source.delete #=> true
389
+ feed.delete #=> true
332
390
  ```
333
391
 
334
392
 
@@ -353,36 +411,28 @@ transaction.id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
353
411
  transaction.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
354
412
  transaction.account #=> #<PrintReleaf::Account>
355
413
  transaction.project_id #=> "692bb68d-64aa-4a79-8a08-d373fb0d8752"
356
- transaction.account #=> #<PrintReleaf::Forestry::Project>
414
+ transaction.project #=> #<PrintReleaf::Forestry::Project>
357
415
  transaction.certificate_id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
358
- transaction.account #=> #<PrintReleaf::Certificate>
416
+ transaction.certificate #=> #<PrintReleaf::Certificate>
417
+ transaction.quote_id #=> "83d12ee9-a187-489d-a93f-3096238f1f86"
418
+ transaction.quote #=> #<PrintReleaf::Quote>
359
419
  transaction.date #=> "2015-10-22T01:52:12Z"
420
+ transaction.pages #=> 525377
360
421
  transaction.trees #=> 63.048
361
- transaction.items #=> [#<PrintReleaf::TransactionItem>, #<PrintReleaf::TransactionItem>]
362
422
  ```
363
423
 
364
424
  ### Creating a Transaction
365
425
 
366
426
  ```ruby
367
- # Providing only trees:
427
+ # By providing total number of pages:
428
+ transaction = PrintReleaf::Transaction.create(trees: 16000) #=> #<PrintReleaf::Transaction>
429
+
430
+ # Or by providing total number of trees:
368
431
  transaction = PrintReleaf::Transaction.create(trees: 2.0) #=> #<PrintReleaf::Transaction>
369
432
 
370
- # or providing raw paper specs:
433
+ # Or by providing a `quote_id` to convert a quote to a transaction
371
434
  transaction = PrintReleaf::Transaction.create(
372
- items: [
373
- {
374
- pages: 20000,
375
- width: 0.2127,
376
- height: 0.2762,
377
- paper_type_id: "a11c7abc-011e-462f-babb-3c6375fa6473"
378
- },
379
- {
380
- pages: 400000,
381
- width: 0.2127,
382
- height: 0.2762,
383
- paper_type_id: "bbd0f271-2f9e-494c-b2af-7f9354b310ad"
384
- }
385
- ]
435
+ quote_id: "83d12ee9-a187-489d-a93f-3096238f1f86"
386
436
  ) #=> #<PrintReleaf::Transaction>
387
437
  ```
388
438
 
@@ -518,7 +568,7 @@ PrintReleaf will raise exceptions for most failure scenarios, including invalid
518
568
 
519
569
  ```ruby
520
570
  begin
521
- # Use PrintReleaf to make requests...
571
+ # Make requests...
522
572
  rescue PrintReleaf::RateLimitExceeded => e
523
573
  # Too many requests made to the API too quickly
524
574
  rescue PrintReleaf::BadRequest => e
@@ -561,5 +611,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/printr
561
611
 
562
612
  ## License
563
613
 
564
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
614
+ The gem is available as open feed under the terms of the [MIT License](http://openfeed.org/licenses/MIT).
565
615
 
@@ -23,10 +23,11 @@ require "printreleaf/paper/type"
23
23
  require "printreleaf/account"
24
24
  require "printreleaf/certificate"
25
25
  require "printreleaf/deposit"
26
+ require "printreleaf/feed"
26
27
  require "printreleaf/invitation"
28
+ require "printreleaf/quote_item"
29
+ require "printreleaf/quote"
27
30
  require "printreleaf/server"
28
- require "printreleaf/source"
29
- require "printreleaf/transaction_item"
30
31
  require "printreleaf/transaction"
31
32
  require "printreleaf/user"
32
33
  require "printreleaf/volume_period"
@@ -23,11 +23,11 @@ module PrintReleaf
23
23
  property :mtd_pages, transform_with: Transforms::Integer
24
24
  property :qtd_pages, transform_with: Transforms::Integer
25
25
  property :ytd_pages, transform_with: Transforms::Integer
26
- property :lifetime_pages, transform_with: Transforms::Integer
26
+ property :ltd_pages, transform_with: Transforms::Integer
27
27
  property :mtd_trees, transform_with: Transforms::Float
28
28
  property :qtd_trees, transform_with: Transforms::Float
29
29
  property :ytd_trees, transform_with: Transforms::Float
30
- property :lifetime_trees, transform_with: Transforms::Float
30
+ property :ltd_trees, transform_with: Transforms::Float
31
31
 
32
32
  def self.mine
33
33
  response = PrintReleaf.get("/account")
@@ -72,6 +72,10 @@ module PrintReleaf
72
72
  @deposits ||= Relation.new(self, Deposit)
73
73
  end
74
74
 
75
+ def feeds
76
+ @feeds ||= Relation.new(self, Feed)
77
+ end
78
+
75
79
  def invitations
76
80
  @invitations ||= Relation.new(self, Invitation)
77
81
  end
@@ -80,10 +84,6 @@ module PrintReleaf
80
84
  @servers ||= Relation.new(self, Server)
81
85
  end
82
86
 
83
- def sources
84
- @sources ||= Relation.new(self, Source)
85
- end
86
-
87
87
  def transactions
88
88
  @transactions ||= Relation.new(self, Transaction)
89
89
  end
@@ -9,7 +9,7 @@ module PrintReleaf
9
9
 
10
10
  property :id
11
11
  property :account_id
12
- property :source_id
12
+ property :feed_id
13
13
  property :date, transform_with: Transforms::Date
14
14
  property :pages, transform_with: Transforms::Integer
15
15
  property :width, transform_with: Transforms::Float
@@ -21,9 +21,9 @@ module PrintReleaf
21
21
  @account ||= Account.find(account_id)
22
22
  end
23
23
 
24
- def source
25
- return nil if source_id.nil?
26
- @source ||= Source.find(source_id)
24
+ def feed
25
+ return nil if feed_id.nil?
26
+ @feed ||= Feed.find(feed_id)
27
27
  end
28
28
 
29
29
  def paper_type
@@ -1,6 +1,6 @@
1
1
  module PrintReleaf
2
- class Source < Resource
3
- path "/sources"
2
+ class Feed < Resource
3
+ path "/feeds"
4
4
 
5
5
  action :find
6
6
  action :list
@@ -0,0 +1,32 @@
1
+ module PrintReleaf
2
+ class Quote < Resource
3
+ path "/quotes"
4
+
5
+ action :find
6
+ action :list
7
+ action :create
8
+ action :delete
9
+
10
+ property :id
11
+ property :account_id
12
+ property :project_id
13
+ property :transaction_id
14
+ property :created_at, transform_with: Transforms::Date
15
+ property :standard_pages, transform_with: Transforms::Integer
16
+ property :trees, transform_with: Transforms::Float
17
+ property :msrp_rate, transform_with: Transforms::Float
18
+ property :msrp_price, transform_with: Transforms::Float
19
+ property :items
20
+ coerce_key :items, Array[QuoteItem]
21
+
22
+ def account
23
+ @account ||= Account.find(account_id)
24
+ end
25
+
26
+ def transaction
27
+ return nil if transaction_id.nil?
28
+ @transaction ||= Transaction.find(transaction_id)
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,15 @@
1
+ module PrintReleaf
2
+ class QuoteItem < Resource
3
+ property :quantity, transform_with: Transforms::Integer
4
+ property :width, transform_with: Transforms::Float
5
+ property :height, transform_with: Transforms::Float
6
+ property :density, transform_with: Transforms::Float
7
+ property :paper_type_id
8
+
9
+ def paper_type
10
+ return nil if paper_type_id.nil?
11
+ @paper_type ||= Paper::Type.find(paper_type_id)
12
+ end
13
+ end
14
+ end
15
+
@@ -11,10 +11,10 @@ module PrintReleaf
11
11
  property :account_id
12
12
  property :project_id
13
13
  property :certificate_id
14
+ property :quote_id
14
15
  property :date, transform_with: Transforms::Date
16
+ property :pages, transform_with: Transforms::Integer
15
17
  property :trees, transform_with: Transforms::Float
16
- property :items
17
- coerce_key :items, Array[TransactionItem]
18
18
 
19
19
  def account
20
20
  @account ||= Account.find(account_id)
@@ -27,6 +27,11 @@ module PrintReleaf
27
27
  def certificate
28
28
  @certificate ||= Certificate.find(certificate_id)
29
29
  end
30
+
31
+ def quote
32
+ return nil if quote_id.nil?
33
+ @quote ||= Quote.find(quote_id)
34
+ end
30
35
  end
31
36
  end
32
37
 
@@ -1,3 +1,3 @@
1
1
  module PrintReleaf
2
- VERSION = "1.0.3"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: printreleaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey O'Hara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -109,15 +109,16 @@ files:
109
109
  - lib/printreleaf/certificate.rb
110
110
  - lib/printreleaf/deposit.rb
111
111
  - lib/printreleaf/error.rb
112
+ - lib/printreleaf/feed.rb
112
113
  - lib/printreleaf/forestry/project.rb
113
114
  - lib/printreleaf/invitation.rb
114
115
  - lib/printreleaf/paper/type.rb
116
+ - lib/printreleaf/quote.rb
117
+ - lib/printreleaf/quote_item.rb
115
118
  - lib/printreleaf/relation.rb
116
119
  - lib/printreleaf/resource.rb
117
120
  - lib/printreleaf/server.rb
118
- - lib/printreleaf/source.rb
119
121
  - lib/printreleaf/transaction.rb
120
- - lib/printreleaf/transaction_item.rb
121
122
  - lib/printreleaf/transforms.rb
122
123
  - lib/printreleaf/user.rb
123
124
  - lib/printreleaf/util.rb
@@ -1,15 +0,0 @@
1
- module PrintReleaf
2
- class TransactionItem < Resource
3
- property :pages, transform_with: Transforms::Integer
4
- property :width, transform_with: Transforms::Float
5
- property :height, transform_with: Transforms::Float
6
- property :density, transform_with: Transforms::Float
7
- property :paper_type_id
8
-
9
- def paper_type
10
- return nil if paper_type_id.nil?
11
- @paper_type ||= Paper::Type.find(paper_type_id)
12
- end
13
- end
14
- end
15
-