printreleaf 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 486b2cb5c05b402a052003a10bc002bf87fbaf52
4
+ data.tar.gz: 10d5cf04397909af9b2728aae27ca10b6db3ad4c
5
+ SHA512:
6
+ metadata.gz: 4228e9b32e587d3436ce0d0b96c639a9fa16a97d0666d3d5e15ccef4a817637431c807c53fbf1ecd50156eba95b7289acf6266e229ac19fad3c7948243d1394b
7
+ data.tar.gz: d0010720154d6d3b0275d00cd15fdc0f400a960d3bd58c7e7887f63b8b87a3104ac4fd5a216be3c90b336e17524b7ffce474fc81a486a7eb76c0a21bf13f4c32
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ .DS_Store
12
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 PrintReleaf Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
@@ -0,0 +1,563 @@
1
+ # PrintReleaf Ruby API   [![Build Status](https://travis-ci.org/PrintReleaf/printreleaf-ruby.svg)](https://travis-ci.org/PrintReleaf/printreleaf-ruby) [![Code Climate](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby/badges/gpa.svg)](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby) [![Test Coverage](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby/badges/coverage.svg)](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby/coverage) [![Issue Count](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby/badges/issue_count.svg)](https://codeclimate.com/github/PrintReleaf/printreleaf-ruby)
2
+
3
+ Ruby toolkit for the [PrintReleaf API](https://printreleaf.com/docs/api).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'printreleaf'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install printreleaf
20
+
21
+
22
+ ## API and Object Reference
23
+
24
+ Complete API spec and object reference can be found here: [printreleaf.com/docs/api](https://printreleaf.com/docs/api).
25
+
26
+
27
+ ## Configuration
28
+
29
+ ```ruby
30
+ PrintReleaf.api_key = "<your PrintReleaf API key>"
31
+ ```
32
+
33
+ `config/initializers/printreleaf.rb` is a good place for this if you are using Rails.
34
+
35
+
36
+ # Usage
37
+
38
+ ## Accounts
39
+
40
+ ### My Account
41
+
42
+ ```ruby
43
+ account = PrintReleaf::Account.mine #=> #<PrintReleaf::Account>
44
+ account.id #=> "a2c031fa-6599-4939-8bc6-8128881953c4"
45
+ account.name #=> "My Account"
46
+ account.role #=> "customer"
47
+ account.created_at #=> "2014-03-06T23:06:23+00:00"
48
+ account.parent_id #=> nil
49
+ account.status #=> "active"
50
+ account.activated_at #=> "2014-03-06T23:06:23+00:00"
51
+ account.deactivated_at #=> nil
52
+ account.accounts_count #=> 2
53
+ account.users_count #=> 2
54
+ account.mtd_pages #=> 1234
55
+ account.qtd_pages #=> 12345
56
+ account.ytd_pages #=> 123456
57
+ account.lifetime_pages #=> 1234567
58
+ account.mtd_trees #=> 0.15
59
+ account.qtd_trees #=> 1.48
60
+ account.ytd_trees #=> 14.82
61
+ account.lifetime_trees #=> 148.1
62
+ ```
63
+
64
+ ### Listing Accounts
65
+
66
+ ```ruby
67
+ PrintReleaf::Account.list #=> [#<PrintReleaf::Account>, #<PrintReleaf::Account>]
68
+ ```
69
+
70
+ ### Retrieving an Account
71
+
72
+ ```ruby
73
+ PrintReleaf::Account.find("a2c031fa-6599-4939-8bc6-8128881953c4") #=> #<PrintReleaf::Account>
74
+ ```
75
+
76
+ ### Creating an Account
77
+
78
+ ```ruby
79
+ account = PrintReleaf::Account.create(name: "Account A") #=> #<PrintReleaf::Account>
80
+ ```
81
+
82
+ ### Updating an Account
83
+
84
+ ```ruby
85
+ account.name = "Account B"
86
+ account.save #=> true
87
+ ```
88
+
89
+ ### Activating an Account
90
+
91
+ ```ruby
92
+ account.activate #=> true
93
+ ```
94
+
95
+ ### Deactivating an Account
96
+
97
+ ```ruby
98
+ account.deactivate #=> true
99
+ ```
100
+
101
+ ## Certificates
102
+
103
+ ### Listing Certificates
104
+
105
+ ```ruby
106
+ PrintReleaf::Certificate.list #=> [#<PrintReleaf::Certificate>, #<PrintReleaf::Certificate>]
107
+ # -or-
108
+ account.certificates #=> [#<PrintReleaf::Certificate>, #<PrintReleaf::Certificate>]
109
+ ```
110
+
111
+ ### Retrieving a Certificate
112
+
113
+ ```ruby
114
+ certificate = PrintReleaf::Certificate.find("ae630937-e15b-4da5-98de-bb68eefe2a12") #=> #<PrintReleaf::Certificate>
115
+ # -or-
116
+ certificate = account.certificates.find("ae630937-e15b-4da5-98de-bb68eefe2a12") #=> #<PrintReleaf::Certificate>
117
+
118
+ certificate.id #=> "ae630937-e15b-4da5-98de-bb68eefe2a12"
119
+ certificate.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
120
+ certificate.account #=> #<PrintReleaf::Account>
121
+ certificate.date #=> "2017-02-28T23:59:59Z"
122
+ certificate.pages #=> 2469134
123
+ certificate.trees #=> 296.31
124
+ certificate.project_id #=> "5d3b468f-c0a3-4e7c-bed4-2dcce9d3f0f9"
125
+ certificate.project #=> #<PrintReleaf::Forestry::Project>
126
+ certificate.url #=> "https://printreleaf.com/certificates/ae630937-e15b-4da5-98de-bb68eefe2a12",
127
+ certificate.pdf_url #=> "https://printreleaf.com/certificates/ae630937-e15b-4da5-98de-bb68eefe2a12.pdf"
128
+ ```
129
+
130
+
131
+ ## Deposits
132
+
133
+ ### Listing Deposits
134
+
135
+ ```ruby
136
+ PrintReleaf::Deposit.list #=> [#<PrintReleaf::Deposit>, #<PrintReleaf::Deposit>]
137
+ # -or-
138
+ account.deposits #=> [#<PrintReleaf::Deposit>, #<PrintReleaf::Deposit>]
139
+ ```
140
+
141
+ ### Retrieving a Deposit
142
+
143
+ ```ruby
144
+ deposit = PrintReleaf::Deposit.find("a86d591c-3c29-4bef-82c3-7a007fb6b19c") #=> #<PrintReleaf::Deposit>
145
+ # -or-
146
+ deposit = account.deposits.find("a86d591c-3c29-4bef-82c3-7a007fb6b19c") #=> #<PrintReleaf::Deposit>
147
+
148
+ deposit.id #=> "a86d591c-3c29-4bef-82c3-7a007fb6b19c"
149
+ deposit.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
150
+ deposit.account #=> #<PrintReleaf::Account>
151
+ deposit.source_id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
152
+ deposit.source #=> #<PrintReleaf::Source>
153
+ deposit.date #=> "2016-07-05T12:29:12Z"
154
+ deposit.pages #=> 20000
155
+ deposit.width #=> 0.2127
156
+ deposit.height #=> 0.2762
157
+ deposit.density #=> 216.0
158
+ deposit.paper_type_id #=> "a11c7abc-011e-462f-babb-3c6375fa6473
159
+ deposit.paper_type #=> #<PrintReleaf::Paper::Type>
160
+ ```
161
+
162
+ ### Creating a Deposit
163
+
164
+ ```ruby
165
+ deposit = PrintReleaf::Deposit.create(pages: 16_666) #=> #<PrintReleaf::Deposit>
166
+ ```
167
+
168
+ ### Deleting a Deposit
169
+
170
+ ```ruby
171
+ deposit.delete #=> true
172
+ ```
173
+
174
+
175
+ ## Invitations
176
+
177
+ ### Listing Invitations
178
+
179
+ ```ruby
180
+ PrintReleaf::Invitation.list #=> [#<PrintReleaf::Invitation>, #<PrintReleaf::Invitation>]
181
+ # -or-
182
+ account.invitations #=> [#<PrintReleaf::Invitation>, #<PrintReleaf::Invitation>]
183
+ ```
184
+
185
+ ### Retrieving an Invitation
186
+
187
+ ```ruby
188
+ invitation = PrintReleaf::Invitation.find("26370b1e-15a5-4449-b3b1-622e99003d3f") #=> #<PrintReleaf::Invitation>
189
+ # -or-
190
+ invitation = account.invitations.find("26370b1e-15a5-4449-b3b1-622e99003d3f") #=> #<PrintReleaf::Invitation>
191
+
192
+ invitation.id #=> "26370b1e-15a5-4449-b3b1-622e99003d3f"
193
+ invitation.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
194
+ invitation.account #=> #<PrintReleaf::Account>
195
+ invitation.email #=> "sally@example.com"
196
+ invitation.created_at #=> "2016-03-07T00:04:09Z
197
+ ```
198
+
199
+ ### Creating an Invitation
200
+
201
+ ```ruby
202
+ invitation = PrintReleaf::Invitation.create(email: "person@example.com") #=> #<PrintReleaf::Invitation>
203
+ ```
204
+
205
+ ### Deleting an Invitation
206
+
207
+ ```ruby
208
+ invitation.delete #=> true
209
+ ```
210
+
211
+
212
+ ## Servers
213
+
214
+ ### Listing Servers
215
+
216
+ ```ruby
217
+ PrintReleaf::Server.list #=> [#<PrintReleaf::Server>, #<PrintReleaf::Server>]
218
+ # -or-
219
+ account.servers #=> [#<PrintReleaf::Server>, #<PrintReleaf::Server>]
220
+ ```
221
+
222
+ ### Retrieving a Server
223
+
224
+ ```ruby
225
+ server = PrintReleaf::Server.find("eadabb78-b199-43cb-adbd-ab36ce5c5a10") #=> #<PrintReleaf::Server>
226
+ # -or-
227
+ server = account.servers.find("eadabb78-b199-43cb-adbd-ab36ce5c5a10") #=> #<PrintReleaf::Server>
228
+
229
+ server.id #=> "eadabb78-b199-43cb-adbd-ab36ce5c5a10"
230
+ server.account_id #=> "a2c031fa-6599-4939-8bc6-8128881953c4"
231
+ server.account #=> #<PrintReleaf::Account>
232
+ server.type #=> "fmaudit"
233
+ server.url #=> "https://myfmauditserver.com"
234
+ server.username #=> "MyFMAuditUsername"
235
+ server.created_at #=> "2015-03-07T00:04:09Z"
236
+ ```
237
+
238
+ ### Creating a Server
239
+
240
+ ```ruby
241
+ server = PrintReleaf::Server.create(
242
+ type: "printfleet",
243
+ url: "https://myprintfleetserver.com",
244
+ username: "MyPrintFleetUsername",
245
+ password: "MyPrintFleetPassword"
246
+ ) #=> #<PrintReleaf::Server>
247
+ ```
248
+
249
+ ### Updating a Server
250
+
251
+ ```ruby
252
+ server.url = "https://example.com"
253
+ server.save #=> true
254
+ ```
255
+
256
+ ### Deleting a Server
257
+
258
+ ```ruby
259
+ server.delete #=> true
260
+ ```
261
+
262
+
263
+ ## Sources
264
+
265
+ ### Listing Sources
266
+
267
+ ```ruby
268
+ PrintReleaf::Source.list #=> [#<PrintReleaf::Source>, #<PrintReleaf::Source>]
269
+ # -or-
270
+ account.sources #=> [#<PrintReleaf::Source>, #<PrintReleaf::Source>]
271
+ ```
272
+
273
+ ### Retrieving a Source
274
+
275
+ ```ruby
276
+ source = PrintReleaf::Source.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Source>
277
+ # -or-
278
+ source = account.sources.find("44e182ed-cd50-4fa1-af90-e77dd6d6a78c") #=> #<PrintReleaf::Source>
279
+
280
+ source.id #=> "44e182ed-cd50-4fa1-af90-e77dd6d6a78c"
281
+ source.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
282
+ source.account #=> #<PrintReleaf::Account>
283
+ source.type #=> "fmaudit"
284
+ source.server_id #=> "eadabb78-b199-43cb-adbd-ab36ce5c5a10"
285
+ source.server #=> #<PrintReleaf::Server>
286
+ source.external_id #=> "456"
287
+ source.collection_scope #=> "managed_only"
288
+ source.created_at #=> "2016-03-07T00:04:09Z"
289
+ source.status #=> "active"
290
+ source.activated_at #=> "2016-03-07T00:04:09Z"
291
+ source.deactivated_at #=> nil
292
+ source.health_check #=> "healthy"
293
+ source.health_check_checked_at #=> "2017-03-07T00:04:09Z"
294
+ source.health_check_changed_at #=> "2017-03-07T00:04:09Z"
295
+ ```
296
+
297
+ ### Creating a Source
298
+
299
+ ```ruby
300
+ source = PrintReleaf::Source.create(
301
+ type: "printfleet",
302
+ server_id: "9a6a1ced-4e71-4919-9d6d-25075834c404",
303
+ external_id: "732ec0d3-20e3-439e-94e6-e64b40eb533a"
304
+ ) #=> #<PrintReleaf::Source>
305
+ ```
306
+
307
+ ### Updating a Source
308
+
309
+ ```ruby
310
+ source.external_id = "abc123"
311
+ source.save #=> true
312
+ ```
313
+
314
+ ### Activating a Source
315
+
316
+ ```ruby
317
+ source.activate #=> true
318
+ ```
319
+
320
+ ### Deactivating a Source
321
+
322
+ ```ruby
323
+ source.deactivate #=> true
324
+ ```
325
+
326
+ ### Deleting a Source
327
+
328
+ ```ruby
329
+ source.delete #=> true
330
+ ```
331
+
332
+
333
+ ## Transactions
334
+
335
+ ### Listing Transactions
336
+
337
+ ```ruby
338
+ PrintReleaf::Transaction.list #=> [#<PrintReleaf::Transaction>, #<PrintReleaf::Transaction>]
339
+ # -or-
340
+ account.transactions #=> [#<PrintReleaf::Transaction>, #<PrintReleaf::Transaction>]
341
+ ```
342
+
343
+ ### Retrieving a Transaction
344
+
345
+ ```ruby
346
+ transaction = PrintReleaf::Transaction.find("70af5540-e3ec-4db7-bc45-4fb65b74368b") #=> #<PrintReleaf::Transaction>
347
+ # -or-
348
+ transaction = account.transactions.find("70af5540-e3ec-4db7-bc45-4fb65b74368b") #=> #<PrintReleaf::Transaction>
349
+
350
+ transaction.id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
351
+ transaction.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
352
+ transaction.account #=> #<PrintReleaf::Account>
353
+ transaction.project_id #=> "692bb68d-64aa-4a79-8a08-d373fb0d8752"
354
+ transaction.account #=> #<PrintReleaf::Forestry::Project>
355
+ transaction.certificate_id #=> "70af5540-e3ec-4db7-bc45-4fb65b74368b"
356
+ transaction.account #=> #<PrintReleaf::Certificate>
357
+ transaction.date #=> "2015-10-22T01:52:12Z"
358
+ transaction.trees #=> 63.048
359
+ transaction.items #=> [#<PrintReleaf::TransactionItem>, #<PrintReleaf::TransactionItem>]
360
+ ```
361
+
362
+ ### Creating a Transaction
363
+
364
+ ```ruby
365
+ # Providing only trees:
366
+ transaction = PrintReleaf::Transaction.create(trees: 2.0) #=> #<PrintReleaf::Transaction>
367
+
368
+ # or providing raw paper specs:
369
+ transaction = PrintReleaf::Transaction.create(
370
+ items: [
371
+ {
372
+ pages: 20000,
373
+ width: 0.2127,
374
+ height: 0.2762,
375
+ paper_type_id: "a11c7abc-011e-462f-babb-3c6375fa6473"
376
+ },
377
+ {
378
+ pages: 400000,
379
+ width: 0.2127,
380
+ height: 0.2762,
381
+ paper_type_id: "bbd0f271-2f9e-494c-b2af-7f9354b310ad"
382
+ }
383
+ ]
384
+ ) #=> #<PrintReleaf::Transaction>
385
+ ```
386
+
387
+ ### Deleting a Transaction
388
+
389
+ ```ruby
390
+ transaction.delete #=> true
391
+ ```
392
+
393
+
394
+ ## Users
395
+
396
+ ### Listing Users
397
+
398
+ ```ruby
399
+ PrintReleaf::User.list #=> [#<PrintReleaf::User>, #<PrintReleaf::User>]
400
+ # -or-
401
+ account.users #=> [#<PrintReleaf::User>, #<PrintReleaf::User>]
402
+ ```
403
+
404
+ ### Retrieving a User
405
+
406
+ ```ruby
407
+ user = PrintReleaf::User.find("5f25569f-ec0d-4ff3-a6ce-0456ac79b84d") #=> #<PrintReleaf::User>
408
+ # -or-
409
+ user = account.users.find("5f25569f-ec0d-4ff3-a6ce-0456ac79b84d") #=> #<PrintReleaf::User>
410
+
411
+ user.id #=> "5f25569f-ec0d-4ff3-a6ce-0456ac79b84d"
412
+ user.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
413
+ user.account #=> #<PrintReleaf::Account>
414
+ user.name #=> "Sally Example"
415
+ user.email #=> "sally@example.com"
416
+ user.created_at #=> "2015-03-07T00:04:09Z
417
+ ```
418
+
419
+ ### Deleting a User
420
+
421
+ ```ruby
422
+ user.delete #=> true
423
+ ```
424
+
425
+
426
+ ## Volume
427
+
428
+ ### Listing volume history
429
+
430
+ ```ruby
431
+ PrintReleaf::VolumePeriod.list #=> [#<PrintReleaf::VolumePeriod>, #<PrintReleaf::VolumePeriod>]
432
+ # -or-
433
+ account.volume #=> [#<PrintReleaf::VolumePeriod>, #<PrintReleaf::VolumePeriod>]
434
+
435
+ volume_period = account.volume.first
436
+ volume_period.account_id #=> "971d10ac-a912-42c0-aa41-f55adc7b6755"
437
+ volume_period.account #=> #<PrintReleaf::VolumePeriod>
438
+ volume_period.date #=> "2017-01-01T07:00:00Z"
439
+ volume_period.pages #=> 234567
440
+ volume_period.trees #=> 56.3
441
+ ```
442
+
443
+ #### With parameters
444
+
445
+ ```ruby
446
+ PrintReleaf::VolumePeriod.list(
447
+ start_date: "2017-03-01",
448
+ end_date: "2017-03-03",
449
+ period: "daily"
450
+ ) #=> [#<PrintReleaf::VolumePeriod>, #<PrintReleaf::VolumePeriod>, #<PrintReleaf::VolumePeriod>]
451
+ ```
452
+
453
+
454
+ ## Forestry Projects
455
+
456
+ ### Listing Projects
457
+
458
+ ```ruby
459
+ PrintReleaf::Forestry::Project.list #=> [#<PrintReleaf::Forestry::Project>, #<PrintReleaf::Forestry::Project>]
460
+ ```
461
+
462
+ ### Retrieving a Project
463
+
464
+ ```ruby
465
+ project = PrintReleaf::Forestry::Project.find("5d3b468f-c0a3-4e7c-bed4-2dcce9d3f0f9") #=> #<PrintReleaf::Forestry::Project>
466
+ project.id #=> "5d3b468f-c0a3-4e7c-bed4-2dcce9d3f0f9"
467
+ project.name #=> "Madagascar"
468
+ project.status #=> "active"
469
+ project.forest_latitude #=> -15.735844444444444
470
+ project.forest_longitude #=> 46.35879166666667
471
+ project.content_logo #=> "http://s3.amazonaws.com/projects/madagascar/logo.jpg"
472
+ project.content_masthead #=> "http://s3.amazonaws.com/projects/madagascar/masthead.jpg"
473
+ project.content_introduction #=> "Madagascar, due to its isolation from the rest of the world..."
474
+ project.content_body_html #=> "<h1>Madagascar is one of the most threatened ecosystems on the planet..."
475
+ project.content_images #=> ["http://s3.amazonaws.com/projects/madagascar/1.jpg", ...]
476
+ ```
477
+
478
+
479
+ ## Paper Types
480
+
481
+ ### Listing Paper Types
482
+
483
+ ```ruby
484
+ PrintReleaf::Paper::Type.list #=> [#<PrintReleaf::Paper::Type>, #<PrintReleaf::Paper::Type>]
485
+ ```
486
+
487
+ ### Retrieving a Paper Type
488
+
489
+ ```ruby
490
+ project = PrintReleaf::Paper::Type.find("a11c7abc-011e-462f-babb-3c6375fa6473") #=> #<PrintReleaf::Paper::Type>
491
+ paper_type.id #=> "a11c7abc-011e-462f-babb-3c6375fa6473"
492
+ paper_type.account_id #=> "a2c031fa-6599-4939-8bc6-8128881953c4"
493
+ paper_type.account #=> #<PrintReleaf::Account>
494
+ paper_type.name #=> "80# #2 Gloss Cover"
495
+ paper_type.density #=> 216.0
496
+ ```
497
+
498
+ ### Creating a Custom Paper Type
499
+
500
+ ```ruby
501
+ paper_type = PrintReleaf::Paper::Type.create(
502
+ name: "20# Bond/Writing/Ledger",
503
+ density: 74.0
504
+ ) #=> #<PrintReleaf::Paper::Type>
505
+ ```
506
+
507
+ ### Deleting a Paper Type
508
+
509
+ ```ruby
510
+ paper_type.delete #=> true
511
+ ```
512
+
513
+ ## Exceptions
514
+
515
+ PrintReleaf will raise exceptions for most failure scenarios, including invalid parameters, authentication errors, and network errors. Most exceptions will inherit from `PrintReleaf::Error`, making it easy to gracefully handle all possible API exceptions.
516
+
517
+ ```ruby
518
+ begin
519
+ # Use PrintReleaf to make requests...
520
+ rescue PrintReleaf::RateLimitExceeded => e
521
+ # Too many requests made to the API too quickly
522
+ rescue PrintReleaf::BadRequest => e
523
+ # Invalid parameters were supplied to PrintReleaf's API
524
+ rescue PrintReleaf::Unauthorized => e
525
+ # Missing or invalid API key
526
+ rescue PrintReleaf::Forbidden => e
527
+ # The requested action is not permitted
528
+ rescue PrintReleaf::NetworkError => e
529
+ # Network communication with PrintReleaf failed
530
+ rescue PrintReleaf::Error => e
531
+ # Catch all generic PrintReleaf errors
532
+ rescue => e
533
+ # Something else happened, completely unrelated to PrintReleaf
534
+ end
535
+ ```
536
+
537
+
538
+ ## Advanced Options
539
+
540
+ #### Logging
541
+
542
+ Be default, PrintReleaf does not perform any logging. You may provide a logger for PrintReleaf to write to:
543
+
544
+ ```ruby
545
+ require 'logger'
546
+ logger = Logger.new(STDOUT)
547
+ PrintReleaf.logger = logger
548
+ ```
549
+
550
+ If you are using Rails, you can use the Rails logger:
551
+
552
+ ```ruby
553
+ PrintReleaf.logger = Rails.logger
554
+ ```
555
+
556
+ ## Contributing
557
+
558
+ Bug reports and pull requests are welcome on GitHub at https://github.com/printreleaf/printreleaf-ruby.
559
+
560
+ ## License
561
+
562
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
563
+