makeprintable 0.0.1 → 1.0.0
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/Gemfile +2 -1
- data/README.md +63 -1
- data/lib/makeprintable.rb +2 -1
- data/lib/makeprintable/client.rb +2 -2
- data/lib/makeprintable/client/endpoints.rb +16 -4
- data/lib/makeprintable/client/jobs.rb +6 -6
- data/lib/makeprintable/version.rb +1 -1
- data/lib/misc/hash.rb +2 -2
- data/spec/client_spec.rb +0 -1
- data/spec/makeprintable_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- metadata +30 -17
- data/spec/endpoints_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a7c8ca6e2caf206ee7ed9d70d7743c43a3704e9
|
4
|
+
data.tar.gz: 28c4969e50512fde4a63f45a3aa3db4f06c11c19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93e6e8ac440228ad805b87407aa27063795b8c5b7e881c15fc735da48b114471307c9b8d54d12d37b93c59628d84479cc6645b940ec1b62d39e1a3ad2cfd2504
|
7
|
+
data.tar.gz: ab80f2222a57ffe48fa25e7d2a96e110ce0bcd40f5addad37f9170a668ee3e3c1428b284f624bd0405d0b2c496b1729e993ae46efa7f553683298a4b752871af
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1 +1,63 @@
|
|
1
|
-
#
|
1
|
+
# Makeprintable
|
2
|
+
|
3
|
+
Sign up for your api credentials at: https://makeprintable.com/site/login
|
4
|
+
(Sign up is currently invitation only)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem ‘makeprintable’
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install makeprintable
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
Create a new initializer: (config/initializers/makeprintable.rb)
|
22
|
+
|
23
|
+
MakePrintable.configure do |config|
|
24
|
+
config.api_key = ENV[‘makeprintable_api_key’]
|
25
|
+
config.api_secret = ENV[‘makeprintable_api_secret’]
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
## Methods
|
31
|
+
For the official documentation please refer to: https://makeprintable.com/page/3/3D-repair-API
|
32
|
+
|
33
|
+
# Upload a model
|
34
|
+
client = MakePrintable::Client.new
|
35
|
+
client.upload(file: File.open(‘path_to_file’))
|
36
|
+
|
37
|
+
# Return a list of previously uploaded files.
|
38
|
+
client = MakePrintable::Client.new
|
39
|
+
client.items
|
40
|
+
|
41
|
+
# Return specific item information
|
42
|
+
client = MakePrintable::Client.new
|
43
|
+
client.find_item(item_id)
|
44
|
+
|
45
|
+
# Delete a specific item from server.
|
46
|
+
client = MakePrintable::Client.new
|
47
|
+
client.delete_item(item_id)
|
48
|
+
|
49
|
+
# Delete a specific item from server.
|
50
|
+
client = MakePrintable::Client.new
|
51
|
+
client.delete_item(item_id)
|
52
|
+
|
53
|
+
# Repair an uploaded item
|
54
|
+
client = MakePrintable::Client.new
|
55
|
+
client.repair(item_id: item_id, callback_url: ‘optional_url’, name: ‘model_name’, wall_thickness: 1, print_quality: [‘standard’, ‘prototype’, ‘high’], pre_optimize: [0,99], post_optimize: [0,99])
|
56
|
+
|
57
|
+
# Returns repair information for a specific repair request, including status, progress and download links.
|
58
|
+
client = MakePrintable::Client.new
|
59
|
+
client.find_repaired(repair_id)
|
60
|
+
|
61
|
+
# Return a list of repaired items
|
62
|
+
client = MakePrintable::Client.new
|
63
|
+
client.repaired
|
data/lib/makeprintable.rb
CHANGED
@@ -2,6 +2,7 @@ require 'makeprintable/version'
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rest-client'
|
4
4
|
require 'json'
|
5
|
+
require 'crack'
|
5
6
|
|
6
7
|
require File.expand_path('../misc/hash.rb', __FILE__)
|
7
8
|
require File.expand_path('../makeprintable/client.rb', __FILE__)
|
@@ -18,6 +19,6 @@ module MakePrintable
|
|
18
19
|
|
19
20
|
|
20
21
|
class Configuration
|
21
|
-
attr_accessor :api_key
|
22
|
+
attr_accessor :api_key
|
22
23
|
end
|
23
24
|
end
|
data/lib/makeprintable/client.rb
CHANGED
@@ -3,10 +3,10 @@ require File.expand_path('../client/jobs.rb', __FILE__)
|
|
3
3
|
|
4
4
|
module MakePrintable
|
5
5
|
class Client
|
6
|
-
attr_accessor :api_key
|
6
|
+
attr_accessor :api_key
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@api_key
|
9
|
+
@api_key = MakePrintable.configuration.api_key
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module MakePrintable
|
2
2
|
class Client
|
3
3
|
def base_uri(path='/')
|
4
|
-
"
|
4
|
+
"https://api.makeprintable.com/v1#{path}"
|
5
5
|
end
|
6
6
|
|
7
7
|
def configure_payload(path, opts={})
|
@@ -9,15 +9,27 @@ module MakePrintable
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_request(uri)
|
12
|
-
|
12
|
+
begin
|
13
|
+
Crack::XML.parse RestClient::Request.execute(method: :get, url: uri, headers: {key: self.api_key})
|
14
|
+
rescue => e
|
15
|
+
Crack::XML.parse e.response
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def post_request(path, opts)
|
16
|
-
|
20
|
+
begin
|
21
|
+
Crack::XML.parse RestClient.post(base_uri(path), opts, key: self.api_key)
|
22
|
+
rescue => e
|
23
|
+
Crack::XML.parse e.response
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
def delete_request(uri)
|
20
|
-
|
28
|
+
begin
|
29
|
+
Crack::XML.parse RestClient::Request.execute(method: :delete, url: uri, headers: {key: self.api_key})
|
30
|
+
rescue => e
|
31
|
+
Crack::XML.parse e.response
|
32
|
+
end
|
21
33
|
end
|
22
34
|
end
|
23
35
|
end
|
@@ -6,11 +6,6 @@ module MakePrintable
|
|
6
6
|
post_request '/items', opts
|
7
7
|
end
|
8
8
|
|
9
|
-
# Return a list of previously uploaded items
|
10
|
-
def items
|
11
|
-
get_request configure_payload("/items")
|
12
|
-
end
|
13
|
-
|
14
9
|
# Return specific item information
|
15
10
|
def find_item(id)
|
16
11
|
get_request configure_payload("/items/#{id}")
|
@@ -18,7 +13,12 @@ module MakePrintable
|
|
18
13
|
|
19
14
|
# Delete a specific item from server.
|
20
15
|
def delete_item(id)
|
21
|
-
delete_request configure_payload("/
|
16
|
+
delete_request configure_payload("/items/#{id}")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return a list of previously uploaded models
|
20
|
+
def items
|
21
|
+
get_request configure_payload('/items')
|
22
22
|
end
|
23
23
|
|
24
24
|
# Repairs an uploaded item
|
data/lib/misc/hash.rb
CHANGED
data/spec/client_spec.rb
CHANGED
data/spec/makeprintable_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,58 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: makeprintable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis de Vulder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 10.4.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 10.4.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rest-client
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.8.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
|
54
|
+
version: 1.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: crack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.4.2
|
69
|
+
description: Ruby wrapper providing a connection to the makeprintable API the rails
|
70
|
+
way
|
56
71
|
email:
|
57
72
|
- dennisdevulder@gmail.com
|
58
73
|
executables: []
|
@@ -70,7 +85,6 @@ files:
|
|
70
85
|
- lib/misc/hash.rb
|
71
86
|
- lib/misc/object.rb
|
72
87
|
- spec/client_spec.rb
|
73
|
-
- spec/endpoints_spec.rb
|
74
88
|
- spec/makeprintable_spec.rb
|
75
89
|
- spec/spec_helper.rb
|
76
90
|
homepage: http://rubygems.org/gems/makeprintable
|
@@ -100,6 +114,5 @@ summary: Ruby wrapper for detecting flaws in 3D designs and repairing them for 3
|
|
100
114
|
printing. Using the makeprintable API.
|
101
115
|
test_files:
|
102
116
|
- spec/client_spec.rb
|
103
|
-
- spec/endpoints_spec.rb
|
104
117
|
- spec/makeprintable_spec.rb
|
105
118
|
- spec/spec_helper.rb
|
data/spec/endpoints_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe MakePrintable::Client do
|
4
|
-
describe '#base_uri' do
|
5
|
-
it 'should be created from set configuration' do
|
6
|
-
client = MakePrintable::Client.new
|
7
|
-
expect(client.base_uri).to eq "http://api.makeprintable.com/?api_key=123apikey&api_secret=123apisecret"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#configure payload' do
|
12
|
-
it 'should add an extra variable to the base_uri' do
|
13
|
-
client = MakePrintable::Client.new
|
14
|
-
expect(client.configure_payload('/', variable: true)).to eq "http://api.makeprintable.com/?api_key=123apikey&api_secret=123apisecret&variable=true"
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should have no problems chaining variables' do
|
18
|
-
client = MakePrintable::Client.new
|
19
|
-
expect(client.configure_payload('/', variable1: true, variable2: false)).to eq "http://api.makeprintable.com/?api_key=123apikey&api_secret=123apisecret&variable1=true&variable2=false"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|