printnode 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/printnode/account.rb +5 -0
- data/lib/printnode/client.rb +16 -0
- data/lib/printnode/printjob.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42809a5cd95dc96bd18b91b67811650e0c260309
|
4
|
+
data.tar.gz: 849046e8086d36e97531332a14668bb49d664379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d4c32803161dccd13398dd0dd694fc0ee403c9703a191de5b43d2808aec5a967c1d257dbc8dd0287e5c3a910fc17379707da6bc8847a2d54c911b85d08997b
|
7
|
+
data.tar.gz: 0ee1532855057fe51c86db5d3f0678178cca29ef16123b56a044242b0c278c3e5320cd952c766f57c2557da93d5e30938a4da21e9eafa7ff906b7f44a260df46
|
data/lib/printnode/account.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module PrintNode
|
2
|
+
# An object to deal with Account Creation.
|
3
|
+
# @author Jake Torrance
|
4
|
+
# @author PrintNode
|
2
5
|
class Account
|
3
6
|
attr_accessor :firstname
|
4
7
|
attr_accessor :lastname
|
@@ -6,6 +9,7 @@ module PrintNode
|
|
6
9
|
attr_accessor :password
|
7
10
|
attr_accessor :creator_ref
|
8
11
|
|
12
|
+
# Map our object into a hash for JSON Encoding.
|
9
13
|
def to_hash
|
10
14
|
hash = {}
|
11
15
|
hash['firstname'] = @firstname
|
@@ -16,6 +20,7 @@ module PrintNode
|
|
16
20
|
hash
|
17
21
|
end
|
18
22
|
|
23
|
+
# Initialize our object ready for being mapped into a hash.
|
19
24
|
def initialize(firstname, lastname, email, password)
|
20
25
|
@firstname = firstname
|
21
26
|
@lastname = lastname
|
data/lib/printnode/client.rb
CHANGED
@@ -10,6 +10,14 @@ module PrintNode
|
|
10
10
|
# @author Jake Torrance
|
11
11
|
# @author PrintNode
|
12
12
|
class Client
|
13
|
+
|
14
|
+
# If an argument is not a string, map it to a string so it can be escaped
|
15
|
+
# and put into a URL.
|
16
|
+
#
|
17
|
+
# @param obj Object to be mapped into a string and escaped.
|
18
|
+
#
|
19
|
+
# == Returns:
|
20
|
+
# CGI.escaped object.
|
13
21
|
def escape_with_types(obj)
|
14
22
|
obj = obj.to_s unless obj.is_a?(String)
|
15
23
|
CGI.escape(obj)
|
@@ -356,6 +364,13 @@ module PrintNode
|
|
356
364
|
parse_array_to_struct(response_object)
|
357
365
|
end
|
358
366
|
|
367
|
+
# Sends a GET request to /computer/(computer_id)/scales
|
368
|
+
#
|
369
|
+
# @param computer_id [String] a set of computers to be got.
|
370
|
+
#
|
371
|
+
# == Returns:
|
372
|
+
# An Array of OpenStruct objects. The design of this Object will be the same as the ones on the PrintNode API docs.
|
373
|
+
# @see https://www.printnode.com/docs/api/curl/#scales Scales on API Docs
|
359
374
|
def scales(computer_id)
|
360
375
|
end_point_url = '/computer/' +
|
361
376
|
escape_with_types(computer_id) +
|
@@ -363,6 +378,7 @@ module PrintNode
|
|
363
378
|
response_object = JSON.parse(get(end_point_url).body)
|
364
379
|
parse_array_to_struct(response_object)
|
365
380
|
end
|
381
|
+
|
366
382
|
# Sends a GET request to /printers/(set_a), or:
|
367
383
|
# /computers/(set_a)/printers/(set_b) if set_b is used.
|
368
384
|
#
|
data/lib/printnode/printjob.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'base64'
|
2
2
|
module PrintNode
|
3
|
+
# An object for printjob creation.
|
4
|
+
# @author Jake Torrance
|
5
|
+
# @author PrintNode
|
3
6
|
class PrintJob
|
4
7
|
attr_accessor :printer_id
|
5
8
|
attr_accessor :title
|
@@ -7,6 +10,7 @@ module PrintNode
|
|
7
10
|
attr_accessor :content
|
8
11
|
attr_accessor :source
|
9
12
|
|
13
|
+
# Maps the object into a hash ready for JSON Encoding.
|
10
14
|
def to_hash
|
11
15
|
hash = {}
|
12
16
|
hash['printerId'] = @printer_id
|
@@ -21,6 +25,7 @@ module PrintNode
|
|
21
25
|
hash
|
22
26
|
end
|
23
27
|
|
28
|
+
# Initializes the object with the variables required.
|
24
29
|
def initialize(printer_id, title, content_type, content, source)
|
25
30
|
@printer_id = printer_id
|
26
31
|
@title = title
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: printnode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PrintNode
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07
|
12
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|