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 +4 -4
- data/README.md +109 -59
- data/lib/printreleaf.rb +3 -2
- data/lib/printreleaf/account.rb +6 -6
- data/lib/printreleaf/deposit.rb +4 -4
- data/lib/printreleaf/{source.rb → feed.rb} +2 -2
- data/lib/printreleaf/quote.rb +32 -0
- data/lib/printreleaf/quote_item.rb +15 -0
- data/lib/printreleaf/transaction.rb +7 -2
- data/lib/printreleaf/version.rb +1 -1
- metadata +5 -4
- data/lib/printreleaf/transaction_item.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce4ddb5134037b5e6e8ef6b72cb3d04246496db5
|
4
|
+
data.tar.gz: c08337cccecfa720e7494f6d909764d59e99d91d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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.
|
152
|
-
deposit.
|
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
|
-
##
|
323
|
+
## Feeds
|
266
324
|
|
267
|
-
### Listing
|
325
|
+
### Listing Feeds
|
268
326
|
|
269
327
|
```ruby
|
270
|
-
PrintReleaf::
|
328
|
+
PrintReleaf::Feed.list #=> [#<PrintReleaf::Feed>, #<PrintReleaf::Feed>]
|
271
329
|
# -or-
|
272
|
-
account.
|
330
|
+
account.feeds #=> [#<PrintReleaf::Feed>, #<PrintReleaf::Feed>]
|
273
331
|
```
|
274
332
|
|
275
|
-
### Retrieving a
|
333
|
+
### Retrieving a Feed
|
276
334
|
|
277
335
|
```ruby
|
278
|
-
|
336
|
+
feed = PrintReleaf::Feed.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Feed>
|
279
337
|
# -or-
|
280
|
-
|
338
|
+
feed = account.feeds.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Feed>
|
281
339
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
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
|
357
|
+
### Creating a Feed
|
300
358
|
|
301
359
|
```ruby
|
302
|
-
|
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::
|
364
|
+
) #=> #<PrintReleaf::Feed>
|
307
365
|
```
|
308
366
|
|
309
|
-
### Updating a
|
367
|
+
### Updating a Feed
|
310
368
|
|
311
369
|
```ruby
|
312
|
-
|
313
|
-
|
370
|
+
feed.external_id = "abc123"
|
371
|
+
feed.save #=> true
|
314
372
|
```
|
315
373
|
|
316
|
-
### Activating a
|
374
|
+
### Activating a Feed
|
317
375
|
|
318
376
|
```ruby
|
319
|
-
|
377
|
+
feed.activate #=> true
|
320
378
|
```
|
321
379
|
|
322
|
-
### Deactivating a
|
380
|
+
### Deactivating a Feed
|
323
381
|
|
324
382
|
```ruby
|
325
|
-
|
383
|
+
feed.deactivate #=> true
|
326
384
|
```
|
327
385
|
|
328
|
-
### Deleting a
|
386
|
+
### Deleting a Feed
|
329
387
|
|
330
388
|
```ruby
|
331
|
-
|
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.
|
414
|
+
transaction.project #=> #<PrintReleaf::Forestry::Project>
|
357
415
|
transaction.certificate_id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
|
358
|
-
transaction.
|
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
|
-
#
|
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
|
-
#
|
433
|
+
# Or by providing a `quote_id` to convert a quote to a transaction
|
371
434
|
transaction = PrintReleaf::Transaction.create(
|
372
|
-
|
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
|
-
#
|
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
|
614
|
+
The gem is available as open feed under the terms of the [MIT License](http://openfeed.org/licenses/MIT).
|
565
615
|
|
data/lib/printreleaf.rb
CHANGED
@@ -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"
|
data/lib/printreleaf/account.rb
CHANGED
@@ -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 :
|
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 :
|
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
|
data/lib/printreleaf/deposit.rb
CHANGED
@@ -9,7 +9,7 @@ module PrintReleaf
|
|
9
9
|
|
10
10
|
property :id
|
11
11
|
property :account_id
|
12
|
-
property :
|
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
|
25
|
-
return nil if
|
26
|
-
@
|
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
|
@@ -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
|
|
data/lib/printreleaf/version.rb
CHANGED
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
|
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-
|
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
|
-
|