traceparts 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +119 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/traceparts.rb +3 -0
- data/lib/traceparts/cad_format.rb +12 -0
- data/lib/traceparts/catalog.rb +24 -0
- data/lib/traceparts/category.rb +21 -0
- data/lib/traceparts/client.rb +184 -0
- data/lib/traceparts/part.rb +25 -0
- data/lib/traceparts/part_details.rb +26 -0
- data/lib/traceparts/product.rb +19 -0
- data/lib/traceparts/user.rb +21 -0
- data/lib/traceparts/version.rb +3 -0
- data/traceparts.gemspec +28 -0
- metadata +149 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2a43230d74a3765be73beaf25f26e37e72536533
|
|
4
|
+
data.tar.gz: 5dfd7c5db00897d4a3a5f095571e559cc53773bf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 645c42bef8effa5eb3d8e257e86dcc914b83f97d75923686e8ce4731e7c5db74f1ae569a7fbcf5a99748157980ce9678245020a3d9fa594ed6879ebc31ca3515
|
|
7
|
+
data.tar.gz: 5e4ecb607679ed34976a8aa4cb39b4e31cc90f8d8b398217a5ce86f11f8388ccd4eb426bd0c0b9bcd974696a367922023376b0006b1b24edf4dd3026256b8bc0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Zilvinas
|
|
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.
|
data/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Traceparts
|
|
2
|
+
|
|
3
|
+
Minimal Traceparts [traceparts.com](http://www.traceparts.com/developers) API wrapper.
|
|
4
|
+
|
|
5
|
+
Currently it lacks tests and [http error codes](http://www.traceparts.com/developers/http-error-codes/) handling.
|
|
6
|
+
|
|
7
|
+
It can be used for:
|
|
8
|
+
|
|
9
|
+
* [List of catalogs](http://www.traceparts.com/developers/list-catalogs-api/) endpoint
|
|
10
|
+
* [List of categories](http://www.traceparts.com/developers/categories-list-api/) endpoint
|
|
11
|
+
* [List of products](http://www.traceparts.com/developers/products-list-api/) endpoint - Default size is 30000 (could be improved)
|
|
12
|
+
* [PartNumber data](http://www.traceparts.com/developers/partnumber-data-api/) endpoint
|
|
13
|
+
* [Availability of CAD data](http://www.traceparts.com/developers/cad-format-availability-api/) endpoint
|
|
14
|
+
* [Download CAD file](http://www.traceparts.com/developers/download-cad-file-api/) endpoint - extract archive link
|
|
15
|
+
* [User existence](http://www.traceparts.com/developers/user-account-api/) endpoint
|
|
16
|
+
* [User creation](http://www.traceparts.com/developers/user-account-creation-api/) endpoint
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Add this line to your application's Gemfile:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
gem 'traceparts'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
And then execute:
|
|
27
|
+
|
|
28
|
+
$ bundle
|
|
29
|
+
|
|
30
|
+
Or install it yourself as:
|
|
31
|
+
|
|
32
|
+
$ gem install traceparts
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Setup client
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
ACCESS_TOKEN = 'YOUR_TRACEPARTS_ACCESS_TOKEN'
|
|
40
|
+
|
|
41
|
+
client = Traceparts::Client.new(ACCESS_TOKEN)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Some test data
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
id = 'PNEUMADYNE'
|
|
48
|
+
part_number = 'A11-31-14'
|
|
49
|
+
email = 'your@email.com'
|
|
50
|
+
format_id = 11
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Catalog related functionality
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
catalogs = client.catalogs
|
|
57
|
+
catalog = catalogs.first
|
|
58
|
+
|
|
59
|
+
categories = catalog.categories
|
|
60
|
+
category = categories.first
|
|
61
|
+
|
|
62
|
+
category_products = category.products
|
|
63
|
+
category_product = category_products.first
|
|
64
|
+
|
|
65
|
+
catalog_products = catalog.products
|
|
66
|
+
catalog_product = catalog_products.first
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### User related functionality
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
user = client.user(user_email)
|
|
73
|
+
|
|
74
|
+
# Option 1 (suggested)
|
|
75
|
+
user.exists? # true or false
|
|
76
|
+
user.register(company, country) # true or false
|
|
77
|
+
|
|
78
|
+
user.email
|
|
79
|
+
|
|
80
|
+
# Option 2
|
|
81
|
+
client.user_exists?(user_email) # true or false
|
|
82
|
+
client.register_user(user_email, company, country) # true or false
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### PartNumber data related functionality
|
|
86
|
+
|
|
87
|
+
#### Option 1 (suggested)
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
part = client.part(id, part_number, email)
|
|
91
|
+
|
|
92
|
+
details = part.details
|
|
93
|
+
formats = part.available_formats
|
|
94
|
+
download_link = part.download_archive_link(format_id)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Option 2
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
details = client.part_details(id, part_number, email)
|
|
101
|
+
formats = client.available_formats(id, part_number, email)
|
|
102
|
+
download_link = client.download_archive_link(id, part_number, format_id, email)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Or if you want to be fancy and use `pry` instead of `irb` you can also run `rake console` that I have specifically made for easier testing.
|
|
108
|
+
|
|
109
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CGTrader/traceparts.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
119
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "traceparts"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/traceparts.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class Catalog
|
|
3
|
+
attr_reader :id, :title, :picture_url, :published, :updated, :type
|
|
4
|
+
|
|
5
|
+
def initialize(client, data)
|
|
6
|
+
@client = client
|
|
7
|
+
|
|
8
|
+
@id = data.fetch('classificationId')
|
|
9
|
+
@title = data.fetch('title')
|
|
10
|
+
@picture_url = data.fetch('pictureUrl')
|
|
11
|
+
@published = data.fetch('published')
|
|
12
|
+
@updated = data.fetch('updated')
|
|
13
|
+
@type = data.fetch('classType')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def products
|
|
17
|
+
@client.products(id)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def categories
|
|
21
|
+
@client.categories(id)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class Category
|
|
3
|
+
attr_reader :path, :title, :path_caption, :classification_id, :picture_url, :level, :description
|
|
4
|
+
|
|
5
|
+
def initialize(client, data)
|
|
6
|
+
@client = client
|
|
7
|
+
|
|
8
|
+
@path = data.fetch('path')
|
|
9
|
+
@title = data.fetch('title')
|
|
10
|
+
@path_caption = data.fetch('pathCaption')
|
|
11
|
+
@classification_id = data.fetch('classificationId')
|
|
12
|
+
@picture_url = data.fetch('pictureUrl')
|
|
13
|
+
@level = data.fetch('level')
|
|
14
|
+
@description = data.fetch('description')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def products
|
|
18
|
+
@client.products(classification_id, path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'traceparts/catalog'
|
|
4
|
+
require 'traceparts/product'
|
|
5
|
+
require 'traceparts/category'
|
|
6
|
+
require 'traceparts/part'
|
|
7
|
+
require 'traceparts/part_details'
|
|
8
|
+
require 'traceparts/cad_format'
|
|
9
|
+
require 'traceparts/user'
|
|
10
|
+
|
|
11
|
+
module Traceparts
|
|
12
|
+
class Client
|
|
13
|
+
API_BASE = 'http://ws.tracepartsonline.net'
|
|
14
|
+
WEB_SERVICE_PATH = '/tpowebservices'
|
|
15
|
+
|
|
16
|
+
def initialize(api_key)
|
|
17
|
+
@api_key = api_key
|
|
18
|
+
|
|
19
|
+
@connection = Faraday.new(url: API_BASE) do |faraday|
|
|
20
|
+
faraday.adapter(Faraday.default_adapter)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def catalogs
|
|
25
|
+
json_catalogs['classificationList'].map { |catalog| Catalog.new(self, catalog) }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def categories(classification_id)
|
|
29
|
+
json_categories(classification_id)['categorieList'].map { |category| Category.new(self, category) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns product family id's for specified page
|
|
33
|
+
def page_products(classification_id, category_path = nil, page = 1)
|
|
34
|
+
json = json_products(classification_id, category_path, page)
|
|
35
|
+
|
|
36
|
+
products_present?(json) ? bind_products(json) : []
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Returns all product family id's available
|
|
40
|
+
def products(catalog_id, category_path = nil)
|
|
41
|
+
page = 1
|
|
42
|
+
all_products = []
|
|
43
|
+
|
|
44
|
+
while (products_for_page = page_products(catalog_id, category_path, page)).any? do
|
|
45
|
+
all_products.push(*products_for_page)
|
|
46
|
+
|
|
47
|
+
page += 1
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
all_products
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def part_details(classification_id, part_number, user_email)
|
|
54
|
+
json = json_part_details(classification_id, part_number, user_email)
|
|
55
|
+
|
|
56
|
+
PartDetails.new(json)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def available_formats(classification_id, part_number, user_email)
|
|
60
|
+
json = json_available_formats(classification_id, part_number, user_email)
|
|
61
|
+
|
|
62
|
+
json.map { |format| CadFormat.new(self, format) }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def download_archive_link(classification_id, part_number, cad_format_id, user_email)
|
|
66
|
+
response = get_request('DownloadCADPath', {
|
|
67
|
+
'PartNumber' => part_number,
|
|
68
|
+
'ClassificationID' => classification_id,
|
|
69
|
+
'CADFormatID' => cad_format_id,
|
|
70
|
+
'UserEmail' => user_email
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
json = JSON.parse(response.body)
|
|
74
|
+
|
|
75
|
+
json[1][1][1]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def part(classification_id, part_number, user_email)
|
|
79
|
+
Part.new(self, classification_id, part_number, user_email)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def user(user_email)
|
|
83
|
+
User.new(self, user_email)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def user_exists?(user_email)
|
|
87
|
+
response = get_request('CheckLogin', {
|
|
88
|
+
'UserEmail' => user_email
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
json = JSON.parse(response.body)
|
|
92
|
+
|
|
93
|
+
json['registered'] == true
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def register_user(user_email, company, country)
|
|
97
|
+
response = get_request('UserRegistration', {
|
|
98
|
+
'UserEmail' => user_email,
|
|
99
|
+
'company' => company,
|
|
100
|
+
'country' => country
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
json = JSON.parse(response.body)
|
|
104
|
+
|
|
105
|
+
json['registered'] == true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def json_catalogs
|
|
111
|
+
response = get_request('CatalogsList')
|
|
112
|
+
|
|
113
|
+
JSON.parse(response.body)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def json_categories(classification_id)
|
|
117
|
+
response = get_request('CategoriesList', {
|
|
118
|
+
'ClassificationId' => classification_id
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
JSON.parse(response.body)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def json_products(catalog_id, category_path, page)
|
|
125
|
+
response = get_request('ProductsList', {
|
|
126
|
+
'ClassificationID' => catalog_id,
|
|
127
|
+
'Path' => category_path,
|
|
128
|
+
'Page' => page
|
|
129
|
+
})
|
|
130
|
+
json = response.body
|
|
131
|
+
|
|
132
|
+
return {} unless json && json.length >= 2
|
|
133
|
+
|
|
134
|
+
JSON.parse(json)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def json_part_details(classification_id, part_number, user_email)
|
|
138
|
+
response = get_request('PartNumberData', {
|
|
139
|
+
'PartNumber' => part_number,
|
|
140
|
+
'ClassificationID' => classification_id,
|
|
141
|
+
'UserEmail' => user_email
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
JSON.parse(response.body)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def json_available_formats(classification_id, part_number, user_email)
|
|
148
|
+
response = get_request('CADFormatsList', {
|
|
149
|
+
'PartNumber' => part_number,
|
|
150
|
+
'ClassificationID' => classification_id,
|
|
151
|
+
'UserEmail' => user_email
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
JSON.parse(response.body)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def bind_products(json)
|
|
158
|
+
json['productList'].map { |product| Product.new(self, product) }
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def products_present?(json)
|
|
162
|
+
!json['productList'].nil?
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def get_request(endpoint, params = {})
|
|
166
|
+
@connection.get("#{WEB_SERVICE_PATH}/#{endpoint}", default_params.merge(params))
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def post_request(endpoint, params = {})
|
|
170
|
+
@connection.post(endpoint, default_params.merge(params))
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def default_params
|
|
174
|
+
{
|
|
175
|
+
'ApiKey' => @api_key,
|
|
176
|
+
'Format' => 'json',
|
|
177
|
+
options: {
|
|
178
|
+
timeout: 50,
|
|
179
|
+
open_timeout: 50
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class Part
|
|
3
|
+
attr_reader :classification_id, :part_number, :user_email
|
|
4
|
+
|
|
5
|
+
def initialize(client, classification_id, part_number, user_email)
|
|
6
|
+
@client = client
|
|
7
|
+
|
|
8
|
+
@classification_id = classification_id
|
|
9
|
+
@part_number = part_number
|
|
10
|
+
@user_email = user_email
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def details
|
|
14
|
+
@client.part_details(classification_id, part_number, user_email)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def available_formats
|
|
18
|
+
@client.available_formats(classification_id, part_number, user_email)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def download_archive_link(cad_format_id)
|
|
22
|
+
@client.download_archive_link(classification_id, part_number, cad_format_id, user_email)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class PartDetails
|
|
3
|
+
attr_reader :title, :description, :long_description, :big_picture, :manufacturer_id, :manufacturer_name,
|
|
4
|
+
:manufacturer_picture, :manufacturer_description, :manufacturer_emails, :manufacturer_websites,
|
|
5
|
+
:manufacturer_address
|
|
6
|
+
|
|
7
|
+
def initialize(data)
|
|
8
|
+
global_info = data.fetch('globalInfo')
|
|
9
|
+
part_info = global_info.fetch('partInfo')
|
|
10
|
+
manufacturer_info = global_info.fetch('manufacturerInfo')
|
|
11
|
+
|
|
12
|
+
@title = part_info.fetch('titlePart')
|
|
13
|
+
@description = part_info.fetch('description')
|
|
14
|
+
@long_description = part_info.fetch('longDescription')
|
|
15
|
+
@big_picture = part_info.fetch('partPictureUrl')
|
|
16
|
+
@manufacturer_id = part_info.fetch('manufacturerID')
|
|
17
|
+
@manufacturer_name = part_info.fetch('manufacturerName')
|
|
18
|
+
@manufacturer_picture= part_info.fetch('manufacturerPictureUrl')
|
|
19
|
+
|
|
20
|
+
@manufacturer_description = manufacturer_info.fetch('description')
|
|
21
|
+
@manufacturer_emails = manufacturer_info.fetch('emails')
|
|
22
|
+
@manufacturer_websites = manufacturer_info.fetch('webSites')
|
|
23
|
+
@manufacturer_address = manufacturer_info.fetch('address')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class Product
|
|
3
|
+
attr_reader :id, :title, :manufacturer_id, :manufacturer_name, :picture_url, :published, :updated,
|
|
4
|
+
:manufacturer_picture_url
|
|
5
|
+
|
|
6
|
+
def initialize(client, data)
|
|
7
|
+
@client = client
|
|
8
|
+
|
|
9
|
+
@id = data.fetch('partID')
|
|
10
|
+
@title = data.fetch('title')
|
|
11
|
+
@manufacturer_id = data.fetch('manufacturerID')
|
|
12
|
+
@manufacturer_name = data.fetch('manufacturerName')
|
|
13
|
+
@picture_url = data.fetch('partPictureUrl')
|
|
14
|
+
@published = data.fetch('published')
|
|
15
|
+
@updated = data.fetch('updated')
|
|
16
|
+
@manufacturer_picture_url = data.fetch('manufacturerPictureUrl')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Traceparts
|
|
2
|
+
class User
|
|
3
|
+
attr_reader :email, :company, :country
|
|
4
|
+
|
|
5
|
+
def initialize(client, email)
|
|
6
|
+
@client = client
|
|
7
|
+
|
|
8
|
+
@email = email
|
|
9
|
+
@company = nil
|
|
10
|
+
@coutry = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def exists?
|
|
14
|
+
@client.user_exists?(email)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def register(company, country)
|
|
18
|
+
@client.register_user(email, company, country)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/traceparts.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'traceparts/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "traceparts"
|
|
8
|
+
spec.version = Traceparts::VERSION
|
|
9
|
+
spec.authors = ["Zilvinas"]
|
|
10
|
+
spec.email = ["zil.kucinskas@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A Ruby interface to the Traceparts API}
|
|
13
|
+
spec.homepage = "https://github.com/CGTrader/traceparts"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
24
|
+
spec.add_development_dependency "pry"
|
|
25
|
+
|
|
26
|
+
spec.add_dependency "faraday"
|
|
27
|
+
spec.add_dependency "json"
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: traceparts
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Zilvinas
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: faraday
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: json
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description:
|
|
98
|
+
email:
|
|
99
|
+
- zil.kucinskas@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".rspec"
|
|
106
|
+
- ".ruby-version"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- Gemfile
|
|
109
|
+
- LICENSE.txt
|
|
110
|
+
- README.md
|
|
111
|
+
- Rakefile
|
|
112
|
+
- bin/console
|
|
113
|
+
- bin/setup
|
|
114
|
+
- lib/traceparts.rb
|
|
115
|
+
- lib/traceparts/cad_format.rb
|
|
116
|
+
- lib/traceparts/catalog.rb
|
|
117
|
+
- lib/traceparts/category.rb
|
|
118
|
+
- lib/traceparts/client.rb
|
|
119
|
+
- lib/traceparts/part.rb
|
|
120
|
+
- lib/traceparts/part_details.rb
|
|
121
|
+
- lib/traceparts/product.rb
|
|
122
|
+
- lib/traceparts/user.rb
|
|
123
|
+
- lib/traceparts/version.rb
|
|
124
|
+
- traceparts.gemspec
|
|
125
|
+
homepage: https://github.com/CGTrader/traceparts
|
|
126
|
+
licenses:
|
|
127
|
+
- MIT
|
|
128
|
+
metadata: {}
|
|
129
|
+
post_install_message:
|
|
130
|
+
rdoc_options: []
|
|
131
|
+
require_paths:
|
|
132
|
+
- lib
|
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
|
+
requirements:
|
|
140
|
+
- - ">="
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '0'
|
|
143
|
+
requirements: []
|
|
144
|
+
rubyforge_project:
|
|
145
|
+
rubygems_version: 2.4.5.1
|
|
146
|
+
signing_key:
|
|
147
|
+
specification_version: 4
|
|
148
|
+
summary: A Ruby interface to the Traceparts API
|
|
149
|
+
test_files: []
|