OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar by inertia

View this thread on steempeak.com
· @inertia · (edited)
$3.84
OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar
[OpenBazaar API Ruby Client](https://github.com/inertia186/obarc)
==========================
 
A simple OpenBazaar API client for Ruby.

#### Fixes in 0.5.2

* Support for gem release.
* Dependency refresh.
* Deprecation removal.

### Installation

Add the gem to your Gemfile:

```ruby
gem 'obarc'
```
    
Then:

```bash
$ bundle install
```

### Usage

```ruby
require 'obarc'

session = OBarc::Session.new(username: 'username', password: 'password')

profile = session.profile
```
```json
{"profile":
  {"website": "website",
   "public_key": "b7d8f6ee04453e1babde87d12198ecd14be00aa998e85636767d8b00d2603e6d",
   .
   .
   .
   "primary_color": 16777215,
   "background_color": 12832757,
   "email": "email@bogus.com"}}
```
```ruby
session.update_profile(email: 'big@vendor.com')
```
```json
{"success": true}
```
```ruby
session.connected_peers
```
```json
{"peers": [["5.37.3.8", 28467]], "num_peers": 1}
```
If you want to manually upload an image, this will return the image hash.
```ruby
session.upload_image(image: 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAC91JREFUWAktl3mQHOV5xn99zH3u7K1d7Uq7CEkIpNVZRhagQDjKCcaxSIJNIJTjI5XCuakKceXyHy5XnJSr')
```
```json
{"image_hashes": ["a89810619833ef29d373c124ce05f362a313929e"], "success": true}
```

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.

```ruby
session.create_contract(
  expiration_date: '',
  metadata_category: 'physical good',
  title: 'Black Dress',
  description: 'A pretty black dress.',
  currency_code: 'USD',
  price: '19.95',
  process_time: '3 Business Days',
  nsfw: 'false',
  shipping_origin: 'UNITED_STATES',
  ships_to: 'UNITED_STATES',
  est_delivery_domestic: '5-7 Business Days',
  est_delivery_international: '',
  terms_conditions: "We cannot ship to PO Boxes/APO's\n * We cannot combine shipping.\n * No Local Pickup.",
  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.",
  shipping_currency_code: 'USD',
  shipping_domestic: true,
  shipping_international: false,
  keywords: 'dress',
  category: '',
  condition: 'New',
  sku: '123456789',
  image_urls: ['http://i.imgur.com/2KXXHSt.jpg'],
  free_shipping: true
)
```
```json
{"success": true}
```

## Tests

* Clone the client repository into a directory of your choice:
  * `git clone https://github.com/inertia186/obarc.git`
* Navigate into the new folder
  * `cd obarc`
* Basic tests can be invoked as follows:
  * `rake`
* To run tests with parallelization and local code coverage:
  * `HELL_ENABLED=true rake`
* To run tests against a testnet server:
  * `TEST_NET=true OB_SERVER_HOST=localhost OB_USERNAME=username OB_PASSWORD=password rake`

## Docmentation
  * [Session](http://www.rubydoc.info/github/inertia186/obarc/master/OBarc/Session) - Most of what you need in your app is explained here.
  
## Requirements

* `ruby 2.1.5`
* `bundler 1.11`
* `OpenBazaar-Server 1.1.15`

## Get in touch!

If you're using OBarc, I'd love to hear from you.  Drop me a line and tell me what you think!

<center>
  <img src="https://cl.ly/233t0q0v2j0p/obarc-logo.png" />
</center>

## Licence

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.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 114 others
properties (23)
post_id2,335,326
authorinertia
permlinkobarc-v0-5-2-openbazaar-ruby-api-client
categoryopenbazaar
json_metadata"{"app": "steemit/0.1", "format": "markdown", "links": ["https://github.com/inertia186/obarc", "http://www.rubydoc.info/github/inertia186/obarc/master/OBarc/Session", "http://creativecommons.org/publicdomain/zero/1.0/"], "image": ["https://cl.ly/233t0q0v2j0p/obarc-logo.png"], "tags": ["openbazaar", "bitcoin", "blockchain", "life", "cryptocurrency"]}"
created2017-04-05 00:39:18
last_update2017-04-05 00:50:36
depth0
children5
net_rshares17,638,198,149,332
last_payout2017-04-12 00:39:18
cashout_time1969-12-31 23:59:59
total_payout_value3.386 SBD
curator_payout_value0.454 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length4,088
author_reputation227,335,189,892,062
root_title"OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars0
author_curate_reward""
vote details (178)
@christoryan ·
# <center>What is an API token?</center>

## An API token is a key that verifies the user is human with a time stamp. It has gps coordinates, fingerprint, and data that ties you "the user" to a machine,  "your computer."

   ![image](https://i.imgur.com/qhHl6O6.jpg)
properties (22)
post_id2,335,377
authorchristoryan
permlinkre-inertia-obarc-v0-5-2-openbazaar-ruby-api-client-201744t19542258z
categoryopenbazaar
json_metadata"{"app": "esteem/1.4.0", "format": "markdown+html", "tags": "openbazaar"}"
created2017-04-05 00:54:06
last_update2017-04-05 00:54:06
depth1
children2
net_rshares0
last_payout2017-04-12 00:54:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length266
author_reputation4,254,895,407,768
root_title"OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@inertia ·
Actually, in this case, you don't need an API token.  You need an OpenBazaar server running on the latest version, configured with a username/password that the API client can use to connect.
👍  ,
properties (23)
post_id2,335,386
authorinertia
permlinkre-christoryan-re-inertia-obarc-v0-5-2-openbazaar-ruby-api-client-201744t19542258z-20170405t005814970z
categoryopenbazaar
json_metadata"{"app": "steemit/0.1", "tags": ["openbazaar"]}"
created2017-04-05 00:58:15
last_update2017-04-05 00:58:15
depth2
children1
net_rshares18,764,631,405
last_payout2017-04-12 00:58:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length190
author_reputation227,335,189,892,062
root_title"OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (2)
@christoryan ·
Thanks to @madmax828 for the information that I rebuddled with on this post. @inettia Thank you for the heads up as some people do not know these things.
properties (22)
post_id2,335,463
authorchristoryan
permlinkre-inertia-re-christoryan-re-inertia-obarc-v0-5-2-openbazaar-ruby-api-client-201744t19542258z-20170405t011322972z
categoryopenbazaar
json_metadata"{"app": "steemit/0.1", "users": ["madmax828", "inettia"], "tags": ["openbazaar"]}"
created2017-04-05 01:13:24
last_update2017-04-05 01:13:24
depth3
children0
net_rshares0
last_payout2017-04-12 01:13:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length153
author_reputation4,254,895,407,768
root_title"OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@hagbardceline · (edited)
Good job! You have a new follower.
👍  ,
properties (23)
post_id2,340,774
authorhagbardceline
permlinkre-inertia-obarc-v0-5-2-openbazaar-ruby-api-client-20170405t211004354z
categoryopenbazaar
json_metadata"{"app": "steemit/0.1", "tags": ["openbazaar"]}"
created2017-04-05 21:10:09
last_update2017-04-05 21:10:21
depth1
children0
net_rshares272,918,559,621
last_payout2017-04-12 21:10:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length34
author_reputation9,332,543,007,969
root_title"OBarc v0.5.2 - OpenBazaar Ruby API Client #openbazzar"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (2)