semantics3 0.12 → 0.14
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/Changes +9 -0
- data/lib/semantics3.rb +43 -23
- data/semantics3.gemspec +3 -2
- metadata +61 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA512:
|
3
|
+
data.tar.gz: 22de4265f9f747157538aaaea841d973cff01717a5819e3dd1dd7bb6a9c125bec9e13b971def76687173bc0d1f4a59b1902e1aeeab46dad95c6db06387b43c11
|
4
|
+
metadata.gz: 6c965a35c1be53ec53a2ad4e027f4a4f5a09e6e4e51700deb358fc4e2bda2adab23f0079fab104c1459e0c699a6f8660b830140d3a9f5373c197ecb1634192a5
|
5
|
+
SHA1:
|
6
|
+
data.tar.gz: 87eb62a3971fe270b3bb9ff10199184ca32474ca
|
7
|
+
metadata.gz: 89880d6fca2a15b13822ac2d251c61fbef9e9bcd
|
data/Changes
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
Revision history for semantics3-ruby
|
2
2
|
|
3
|
+
0.14 13-07-2016
|
4
|
+
Added ability to use basic auth instead of oauth [Feature]
|
5
|
+
|
6
|
+
0.13 07-03-2016
|
7
|
+
Fixed issues with making POST requests [Bug Fix]
|
8
|
+
|
9
|
+
0.12 30-05-2015
|
10
|
+
Modifying static to a string variable [Bug Fix]
|
11
|
+
|
3
12
|
0.11 28-04-2015
|
4
13
|
Incorrect base url. [Critical Bug Fix]
|
5
14
|
|
data/lib/semantics3.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
require 'rubygems'
|
9
9
|
require 'oauth'
|
10
|
+
require 'curb'
|
10
11
|
require 'uri'
|
11
12
|
require 'cgi'
|
12
13
|
require 'json'
|
@@ -15,9 +16,10 @@ module Semantics3
|
|
15
16
|
@auth={}
|
16
17
|
|
17
18
|
class Base
|
18
|
-
def initialize(api_key,api_secret)
|
19
|
+
def initialize(api_key,api_secret,auth = "oauth")
|
19
20
|
@api_key = api_key
|
20
21
|
@api_secret = api_secret
|
22
|
+
@auth_method = auth
|
21
23
|
|
22
24
|
raise Error.new('API Credentials Missing','You did not supply an api_key. Please sign up at https://semantics3.com/ to obtain your api_key.','api_key') if api_key == ''
|
23
25
|
raise Error.new('API Credentials Missing','You did not supply an api_secret. Please sign up at https://semantics3.com/ to obtain your api_secret.','api_secret') if api_secret == ''
|
@@ -33,26 +35,44 @@ module Semantics3
|
|
33
35
|
def _make_request(endpoint,method = "GET",params)
|
34
36
|
|
35
37
|
base_url = 'https://api.semantics3.com/v1/' #+ endpoint + '?q=' + CGI.escape(params)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
if @auth_method == "basic"
|
39
|
+
base_url = 'https://api.semantics3.com/test/v1/' #+ endpoint + '?q=' + CGI.escape(params)
|
40
|
+
|
41
|
+
if method == "GET"
|
42
|
+
request_data = CGI.escape(params)
|
43
|
+
encoded_url = base_url + endpoint + '?q=' + request_data
|
44
|
+
http = Curl.get(encoded_url) do|http|
|
45
|
+
http.headers['api_key'] = @api_key
|
46
|
+
end
|
47
|
+
JSON.parse http.body_str
|
48
|
+
elsif method == "DELETE"
|
49
|
+
url = base_url + endpoint
|
50
|
+
response = @auth.delete(url,params)
|
51
|
+
JSON.parse response.body
|
52
|
+
elsif method == "POST"
|
53
|
+
url = base_url + endpoint
|
54
|
+
response = @auth.post(url,params.to_json,{'Content-Type' => 'application/json'})
|
55
|
+
JSON.parse response.body
|
56
|
+
else
|
57
|
+
raise Error.new('Invalid Method','You have entered an invalid method. Use GET,DELETE or POST.','method')
|
58
|
+
end
|
59
|
+
else
|
60
|
+
if method == "GET"
|
61
|
+
request_data = CGI.escape(params)
|
62
|
+
encoded_url = base_url + endpoint + '?q=' + request_data
|
63
|
+
response = @auth.get(encoded_url)
|
64
|
+
JSON.parse response.body
|
65
|
+
elsif method == "DELETE"
|
66
|
+
url = base_url + endpoint
|
67
|
+
response = @auth.delete(url,params)
|
68
|
+
JSON.parse response.body
|
69
|
+
elsif method == "POST"
|
70
|
+
url = base_url + endpoint
|
71
|
+
response = @auth.post(url,params.to_json,{'Content-Type' => 'application/json'})
|
72
|
+
JSON.parse response.body
|
73
|
+
else
|
74
|
+
raise Error.new('Invalid Method','You have entered an invalid method. Use GET,DELETE or POST.','method')
|
75
|
+
end
|
56
76
|
end
|
57
77
|
end
|
58
78
|
|
@@ -60,7 +80,7 @@ module Semantics3
|
|
60
80
|
|
61
81
|
class Products < Base
|
62
82
|
|
63
|
-
def initialize api_key, api_secret
|
83
|
+
def initialize api_key, api_secret, auth = 'oauth'
|
64
84
|
super
|
65
85
|
clear()
|
66
86
|
end
|
@@ -278,4 +298,4 @@ module JSON
|
|
278
298
|
false
|
279
299
|
end
|
280
300
|
end
|
281
|
-
end
|
301
|
+
end
|
data/semantics3.gemspec
CHANGED
@@ -2,16 +2,17 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'semantics3'
|
5
|
-
s.version = '0.
|
5
|
+
s.version = '0.14'
|
6
6
|
s.summary = 'Ruby bindings for the Semantics3 API'
|
7
7
|
s.description = 'Get access to a constantly updated database of product and price data. See https://semantics3.com/ for more information.'
|
8
|
-
s.authors = ['Sivamani Varun', 'Mounarajan P A']
|
8
|
+
s.authors = ['Sivamani Varun', 'Mounarajan P A', 'Vinoth Gopinathan']
|
9
9
|
s.email = ['varun@semantics3.com']
|
10
10
|
s.homepage = 'https://semantics3.com'
|
11
11
|
s.require_paths = %w{lib}
|
12
12
|
|
13
13
|
s.add_dependency('json', '~> 1.8', '>= 1.8.1')
|
14
14
|
s.add_dependency('oauth', '~> 0.4', '>= 0.4.6')
|
15
|
+
s.add_dependency('curb', '~> 0.9', '>= 0.9.3')
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
s.require_paths = ['lib']
|
metadata
CHANGED
@@ -1,69 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantics3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.14"
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Sivamani Varun
|
9
8
|
- Mounarajan P A
|
9
|
+
- Vinoth Gopinathan
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
date: 2016-07-14 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
16
17
|
name: json
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
|
-
requirements:
|
20
|
-
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '1.8'
|
23
|
-
- - ! '>='
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: 1.8.1
|
26
|
-
type: :runtime
|
27
18
|
prerelease: false
|
28
|
-
|
29
|
-
|
30
|
-
requirements:
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
31
21
|
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.8"
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
36
26
|
version: 1.8.1
|
37
|
-
|
27
|
+
type: :runtime
|
28
|
+
version_requirements: *id001
|
29
|
+
- !ruby/object:Gem::Dependency
|
38
30
|
name: oauth
|
39
|
-
|
40
|
-
|
41
|
-
requirements:
|
31
|
+
prerelease: false
|
32
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
42
34
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0.4"
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
47
39
|
version: 0.4.6
|
48
40
|
type: :runtime
|
41
|
+
version_requirements: *id002
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: curb
|
49
44
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
requirements:
|
45
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
53
47
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: 0.
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0.9"
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.9.3
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id003
|
55
|
+
description: Get access to a constantly updated database of product and price data. See https://semantics3.com/ for more information.
|
56
|
+
email:
|
62
57
|
- varun@semantics3.com
|
63
58
|
executables: []
|
59
|
+
|
64
60
|
extensions: []
|
61
|
+
|
65
62
|
extra_rdoc_files: []
|
66
|
-
|
63
|
+
|
64
|
+
files:
|
67
65
|
- .gitignore
|
68
66
|
- Changes
|
69
67
|
- Gemfile
|
@@ -74,26 +72,29 @@ files:
|
|
74
72
|
- semantics3.gemspec
|
75
73
|
homepage: https://semantics3.com
|
76
74
|
licenses: []
|
75
|
+
|
76
|
+
metadata: {}
|
77
|
+
|
77
78
|
post_install_message:
|
78
79
|
rdoc_options: []
|
79
|
-
|
80
|
+
|
81
|
+
require_paths:
|
80
82
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
-
|
89
|
-
|
90
|
-
- - ! '>='
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: '0'
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- &id004
|
86
|
+
- ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- *id004
|
93
92
|
requirements: []
|
93
|
+
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.2.2
|
96
96
|
signing_key:
|
97
|
-
specification_version:
|
97
|
+
specification_version: 4
|
98
98
|
summary: Ruby bindings for the Semantics3 API
|
99
99
|
test_files: []
|
100
|
+
|