obarc 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +19 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop.yml +1156 -0
  5. data/.travis.yml +12 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +78 -0
  8. data/README.md +133 -0
  9. data/Rakefile +39 -0
  10. data/doc/OBarc.html +210 -0
  11. data/doc/OBarc/Api.html +883 -0
  12. data/doc/OBarc/Session.html +5399 -0
  13. data/doc/OBarc/Utils.html +117 -0
  14. data/doc/OBarc/Utils/Exceptions.html +115 -0
  15. data/doc/OBarc/Utils/Exceptions/InvalidArgumentError.html +230 -0
  16. data/doc/OBarc/Utils/Exceptions/InvalidElementError.html +218 -0
  17. data/doc/OBarc/Utils/Exceptions/InvalidWordError.html +218 -0
  18. data/doc/OBarc/Utils/Exceptions/MissingArgumentError.html +230 -0
  19. data/doc/OBarc/Utils/Exceptions/OBarcArgumentError.html +151 -0
  20. data/doc/OBarc/Utils/Exceptions/OBarcError.html +291 -0
  21. data/doc/OBarc/Utils/Exceptions/OBarcResponseError.html +520 -0
  22. data/doc/OBarc/Utils/Exceptions/OverLimitError.html +218 -0
  23. data/doc/OBarc/Utils/Exceptions/TimeOutError.html +218 -0
  24. data/doc/OBarc/Utils/Helper.html +115 -0
  25. data/doc/OBarc/Utils/Helper/ObjectExtensions.html +105 -0
  26. data/doc/_index.html +239 -0
  27. data/doc/class_list.html +58 -0
  28. data/doc/css/common.css +1 -0
  29. data/doc/css/full_list.css +57 -0
  30. data/doc/css/style.css +339 -0
  31. data/doc/file.README.html +229 -0
  32. data/doc/file_list.html +60 -0
  33. data/doc/frames.html +26 -0
  34. data/doc/index.html +229 -0
  35. data/doc/js/app.js +219 -0
  36. data/doc/js/full_list.js +181 -0
  37. data/doc/js/jquery.js +4 -0
  38. data/doc/method_list.html +465 -0
  39. data/doc/top-level-namespace.html +112 -0
  40. data/graphics/obarc-logo.png +0 -0
  41. data/graphics/obarc-logo.xcf +0 -0
  42. data/lib/obarc.rb +14 -0
  43. data/lib/obarc/api.rb +220 -0
  44. data/lib/obarc/session.rb +514 -0
  45. data/lib/obarc/utils/exceptions.rb +35 -0
  46. data/lib/obarc/utils/helper.rb +18 -0
  47. data/lib/obarc/version.rb +3 -0
  48. data/obarc.gemspec +32 -0
  49. metadata +276 -0
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ # - "2.0.0"
4
+ # - "2.1.5"
5
+ - "2.2.1"
6
+ - "2.3.0"
7
+ script: TESTOPTS="--verbose" bundle exec rake test
8
+ addons:
9
+ code_climate:
10
+ repo_token: 107a9abd0cb88b0d6ef17f6429daadbf620adc9631bd9d00208914120fedffb6
11
+ notifications:
12
+ slack: galacticaactual:rhAXgZ68aoikbxBBA05xIUVC
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obarc (0.5.2)
5
+ logging (~> 2.1, >= 2.1.0)
6
+ rest-client (~> 1.8, >= 1.8.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.1)
12
+ public_suffix (~> 2.0, >= 2.0.2)
13
+ codeclimate-test-reporter (0.5.2)
14
+ simplecov (>= 0.7.1, < 1.0.0)
15
+ coderay (1.1.1)
16
+ crack (0.4.3)
17
+ safe_yaml (~> 1.0.0)
18
+ docile (1.1.5)
19
+ domain_name (0.5.20170223)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ hashdiff (0.3.2)
22
+ http-cookie (1.0.3)
23
+ domain_name (~> 0.5)
24
+ json (1.8.6)
25
+ little-plugger (1.1.4)
26
+ logging (2.2.0)
27
+ little-plugger (~> 1.1)
28
+ multi_json (~> 1.10)
29
+ method_source (0.8.2)
30
+ mime-types (2.99.3)
31
+ minitest (5.10.1)
32
+ minitest-line (0.6.3)
33
+ minitest (~> 5.0)
34
+ multi_json (1.12.1)
35
+ netrc (0.11.0)
36
+ pry (0.10.4)
37
+ coderay (~> 1.1.0)
38
+ method_source (~> 0.8.1)
39
+ slop (~> 3.4)
40
+ public_suffix (2.0.5)
41
+ rake (11.3.0)
42
+ rest-client (1.8.0)
43
+ http-cookie (>= 1.0.2, < 2.0)
44
+ mime-types (>= 1.16, < 3.0)
45
+ netrc (~> 0.7)
46
+ safe_yaml (1.0.4)
47
+ simplecov (0.11.2)
48
+ docile (~> 1.1.0)
49
+ json (~> 1.8)
50
+ simplecov-html (~> 0.10.0)
51
+ simplecov-html (0.10.0)
52
+ slop (3.6.0)
53
+ unf (0.1.4)
54
+ unf_ext
55
+ unf_ext (0.0.7.2)
56
+ webmock (2.3.2)
57
+ addressable (>= 2.3.6)
58
+ crack (>= 0.3.2)
59
+ hashdiff
60
+ yard (0.8.7.6)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 1.11)
67
+ codeclimate-test-reporter (~> 0.5.2)
68
+ minitest (~> 5.9, >= 5.9.0)
69
+ minitest-line (~> 0.6.3)
70
+ obarc!
71
+ pry (~> 0.10.3)
72
+ rake (~> 11.2, >= 11.2.2)
73
+ simplecov (~> 0.11.2)
74
+ webmock (~> 2.1, >= 2.1.0)
75
+ yard (~> 0.8.7.6)
76
+
77
+ BUNDLED WITH
78
+ 1.14.3
@@ -0,0 +1,133 @@
1
+ [OpenBazaar API Ruby Client](https://github.com/inertia186/obarc)
2
+ ==========================
3
+
4
+ [![Build Status](https://travis-ci.org/inertia186/obarc.svg?branch=master)](https://travis-ci.org/inertia186/obarc) [![Code Climate](https://codeclimate.com/github/inertia186/obarc/badges/gpa.svg)](https://codeclimate.com/github/inertia186/obarc) [![Test Coverage](https://codeclimate.com/github/inertia186/obarc/badges/coverage.svg)](https://codeclimate.com/github/inertia186/obarc)
5
+
6
+ A simple OpenBazaar API client for Ruby.
7
+
8
+ #### Fixes in 0.5.2
9
+
10
+ * Support for gem release.
11
+ * Dependency refresh.
12
+ * Deprecation removal.
13
+
14
+ ### Installation
15
+
16
+ Add the gem to your Gemfile:
17
+
18
+ ```ruby
19
+ gem 'obarc'
20
+ ```
21
+
22
+ Then:
23
+
24
+ ```bash
25
+ $ bundle install
26
+ ```
27
+
28
+ ### Usage
29
+
30
+ ```ruby
31
+ require 'obarc'
32
+
33
+ session = OBarc::Session.new(username: 'username', password: 'password')
34
+
35
+ profile = session.profile
36
+ ```
37
+ ```json
38
+ {"profile":
39
+ {"website": "website",
40
+ "public_key": "b7d8f6ee04453e1babde87d12198ecd14be00aa998e85636767d8b00d2603e6d",
41
+ .
42
+ .
43
+ .
44
+ "primary_color": 16777215,
45
+ "background_color": 12832757,
46
+ "email": "email@bogus.com"}}
47
+ ```
48
+ ```ruby
49
+ session.update_profile(email: 'big@vendor.com')
50
+ ```
51
+ ```json
52
+ {"success": true}
53
+ ```
54
+ ```ruby
55
+ session.connected_peers
56
+ ```
57
+ ```json
58
+ {"peers": [["5.37.3.8", 28467]], "num_peers": 1}
59
+ ```
60
+ If you want to manually upload an image, this will return the image hash.
61
+ ```ruby
62
+ session.upload_image(image: 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAC91JREFUWAktl3mQHOV5xn99zH3u7K1d7Uq7CEkIpNVZRhagQDjKCcaxSIJNIJTjI5XCuakKceXyHy5XnJSr')
63
+ ```
64
+ ```json
65
+ {"image_hashes": ["a89810619833ef29d373c124ce05f362a313929e"], "success": true}
66
+ ```
67
+
68
+ You can also add a new listing with image URLs in the hash. The client will upload them and save the image hashes to the contract.
69
+
70
+ ```ruby
71
+ session.create_contract(
72
+ expiration_date: '',
73
+ metadata_category: 'physical good',
74
+ title: 'Black Dress',
75
+ description: 'A pretty black dress.',
76
+ currency_code: 'USD',
77
+ price: '19.95',
78
+ process_time: '3 Business Days',
79
+ nsfw: 'false',
80
+ shipping_origin: 'UNITED_STATES',
81
+ ships_to: 'UNITED_STATES',
82
+ est_delivery_domestic: '5-7 Business Days',
83
+ est_delivery_international: '',
84
+ terms_conditions: "We cannot ship to PO Boxes/APO's\n * We cannot combine shipping.\n * No Local Pickup.",
85
+ returns: "Your satisfaction is guaranteed! If for any reason you are unhappy with your item, we can arrange a return within 14 days for a full refund, minus shipping cost. Please contact us prior to initiating a return so that we can issue you a refund authorization.",
86
+ shipping_currency_code: 'USD',
87
+ shipping_domestic: true,
88
+ shipping_international: false,
89
+ keywords: 'dress',
90
+ category: '',
91
+ condition: 'New',
92
+ sku: '123456789',
93
+ image_urls: ['http://i.imgur.com/2KXXHSt.jpg'],
94
+ free_shipping: true
95
+ )
96
+ ```
97
+ ```json
98
+ {"success": true}
99
+ ```
100
+
101
+ ## Tests
102
+
103
+ * Clone the client repository into a directory of your choice:
104
+ * `git clone https://github.com/inertia186/obarc.git`
105
+ * Navigate into the new folder
106
+ * `cd obarc`
107
+ * Basic tests can be invoked as follows:
108
+ * `rake`
109
+ * To run tests with parallelization and local code coverage:
110
+ * `HELL_ENABLED=true rake`
111
+ * To run tests against a testnet server:
112
+ * `TEST_NET=true OB_SERVER_HOST=localhost OB_USERNAME=username OB_PASSWORD=password rake`
113
+
114
+ ## Docmentation
115
+ * [Session](http://www.rubydoc.info/github/inertia186/obarc/master/OBarc/Session) - Most of what you need in your app is explained here.
116
+
117
+ ## Requirements
118
+
119
+ * `ruby 2.1.5`
120
+ * `bundler 1.11`
121
+ * `OpenBazaar-Server 1.1.15`
122
+
123
+ ## Get in touch!
124
+
125
+ If you're using OBarc, I'd love to hear from you. Drop me a line and tell me what you think!
126
+
127
+ <center>
128
+ <img src="https://cl.ly/233t0q0v2j0p/obarc-logo.png" />
129
+ </center>
130
+
131
+ ## Licence
132
+
133
+ I don't believe in intellectual "property". If you do, consider OBarc as licensed under a Creative Commons [![CC0](http://i.creativecommons.org/p/zero/1.0/80x15.png)] (http://creativecommons.org/publicdomain/zero/1.0/) License.
@@ -0,0 +1,39 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'yard'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.libs << 'lib'
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ t.ruby_opts << if ENV['HELL_ENABLED']
10
+ '-W2'
11
+ else
12
+ '-W1'
13
+ end
14
+ end
15
+
16
+ YARD::Rake::YardocTask.new do |t|
17
+ t.files = ['lib/**/*.rb']
18
+ end
19
+
20
+ task default: :test
21
+
22
+ task :console do
23
+ exec "irb -r obarc -I ./lib"
24
+ end
25
+
26
+ task :build do
27
+ exec 'gem build obarc.gemspec'
28
+ end
29
+
30
+ task :push do
31
+ exec "gem push obarc-#{OBarc::VERSION}.gem"
32
+ end
33
+
34
+ # We're not going to yank on a regular basis, but this is how it's done if you
35
+ # really want a task for that for some reason.
36
+
37
+ # task :yank do
38
+ # exec "gem yank obarc -v #{OBarc::VERSION}"
39
+ # end
@@ -0,0 +1,210 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: OBarc
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!OBarc.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (O)</a> &raquo;
35
+
36
+
37
+ <span class="title">OBarc</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: OBarc
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+ <dt class="r1">Extended by:</dt>
77
+ <dd class="r1"><span class='object_link'><a href="" title="OBarc (module)">OBarc</a></span></dd>
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dt class="r2">Included in:</dt>
85
+ <dd class="r2"><span class='object_link'><a href="" title="OBarc (module)">OBarc</a></span></dd>
86
+
87
+
88
+
89
+ <dt class="r1 last">Defined in:</dt>
90
+ <dd class="r1 last">lib/obarc.rb<span class="defines">,<br />
91
+ lib/obarc/api.rb,<br /> lib/obarc/version.rb,<br /> lib/obarc/session.rb,<br /> lib/obarc/utils/helper.rb,<br /> lib/obarc/utils/exceptions.rb</span>
92
+ </dd>
93
+
94
+ </dl>
95
+ <div class="clear"></div>
96
+
97
+ <h2>Defined Under Namespace</h2>
98
+ <p class="children">
99
+
100
+
101
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="OBarc/Api.html" title="OBarc::Api (module)">Api</a></span>, <span class='object_link'><a href="OBarc/Utils.html" title="OBarc::Utils (module)">Utils</a></span>
102
+
103
+
104
+
105
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="OBarc/Session.html" title="OBarc::Session (class)">Session</a></span>
106
+
107
+
108
+ </p>
109
+
110
+ <h2>Constant Summary</h2>
111
+
112
+ <dl class="constants">
113
+
114
+ <dt id="VERSION-constant" class="">VERSION =
115
+
116
+ </dt>
117
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.5.2</span><span class='tstring_end'>&#39;</span></span></pre></dd>
118
+
119
+ </dl>
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ <h2>
130
+ Instance Method Summary
131
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
132
+ </h2>
133
+
134
+ <ul class="summary">
135
+
136
+ <li class="public ">
137
+ <span class="summary_signature">
138
+
139
+ <a href="#login%21-instance_method" title="#login! (instance method)">- (Object) <strong>login!</strong>(options) </a>
140
+
141
+
142
+
143
+ </span>
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+ <span class="summary_desc"><div class='inline'></div></span>
154
+
155
+ </li>
156
+
157
+
158
+ </ul>
159
+
160
+
161
+
162
+
163
+ <div id="instance_method_details" class="method_details_list">
164
+ <h2>Instance Method Details</h2>
165
+
166
+
167
+ <div class="method_details first">
168
+ <h3 class="signature first" id="login!-instance_method">
169
+
170
+ - (<tt>Object</tt>) <strong>login!</strong>(options)
171
+
172
+
173
+
174
+
175
+
176
+ </h3><table class="source_code">
177
+ <tr>
178
+ <td>
179
+ <pre class="lines">
180
+
181
+
182
+ 10
183
+ 11
184
+ 12
185
+ 13</pre>
186
+ </td>
187
+ <td>
188
+ <pre class="code"><span class="info file"># File 'lib/obarc.rb', line 10</span>
189
+
190
+ <span class='kw'>def</span> <span class='id identifier rubyid_login!'>login!</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
191
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:base_url</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:protocol</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>://</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:server_host</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:server_port</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>/api/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:api_version</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
192
+ <span class='const'>Session</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>username:</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:username</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>password:</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:password</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>cookies:</span> <span class='const'>Api</span><span class='period'>.</span><span class='id identifier rubyid_post_login'>post_login</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_cookies'>cookies</span><span class='rparen'>)</span>
193
+ <span class='kw'>end</span></pre>
194
+ </td>
195
+ </tr>
196
+ </table>
197
+ </div>
198
+
199
+ </div>
200
+
201
+ </div>
202
+
203
+ <div id="footer">
204
+ Generated on Tue Apr 4 17:29:29 2017 by
205
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
206
+ 0.8.7.6 (ruby-2.2.5).
207
+ </div>
208
+
209
+ </body>
210
+ </html>