Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bliss-client

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bliss-client

  • 1.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Bliss::Client Build Status

Bliss API Ruby client.

Installation

Add this line to your application's Gemfile:

gem 'bliss-client', git: 'git@github.com:fadendaten/bliss-client.git', tag: 'v1.2.0'

And then execute:

bundle

Authorization

The client requires the following environment variables to be set:

BLISS_SERVER=http://sv96.aarboard.ch
BLISS_CLIENT_ID=34osdljwosdf...
BLISS_CLIENT_SECRET=24ljsdfo8t34...

Usage

Creating a Webshop order

order = Bliss::Client::Order.create(
  type: :webshop,
  blizzard_customer_id: 4,
  items: [
    {
      article_id: 3456, # Bliss article id
      quantity: 2,
      price_value: 35.20,
      price_currency: 'CHF'
    },
    {
      article_id: 18462,
      quantity: 1,
      price_value: 120,
      price_currency: 'CHF'
    }
  ],
  delivery_address: {
    salutation: 'Mr Spongebob Squarepants',
    line_1: 'Ananas 3', # optionally pass line_2 and line_3
    zip_code: '12345',
    city: 'Bikini Bottom',
    country_iso3: 'USA'
  },
  remote_id: 234, # the id of the local Webshop order
)

order.id # => id of the Bliss Webshop order

Fetching collections

Collections and their children model the product catalogue of NILE. The Bliss::Client::Collection provides a way to fetch that data.

Fetching all collections without any children with .all
collections = Bliss::Client::Collection.all

This can be useful for fetching all basic information quickly and then use the IDs of some collections to get more info via .find (see below).

Fetch specific collections with .find
ids = [88, 90, 91, 21]
collections = Bliss::Client::Collection.find ids
Fetch specific collections and include children with the include_<whatever> options
ids = [88, 90, 91, 21]
collections = Bliss::Client::Collection.find(
  ids,
  include_programs: true,
  include_styles: true,
  include_articles: true
)

collections.each do |collection|
  # Access programs with Collection#programs.
  collection.programs.each do |program|
    # Access styles with Program#styles.
    program.styles # ...
  end
end
Fetching all necessary data for webshop4
# Make sure we know about all sizes
Bliss::Client::Size.all.each { # create size options type }

# Say webshop4 needs to know about collection 88, 89 and 90.
collection_ids = [88, 89, 90]

# We want EVERYTHING!!
options = {
  include_programs: true,
  include_colors: true,
  include_styles: true,
  include_articles: true,
  include_prices: true
}

collections = Bliss::Client::Collection.find(collection_ids, options)

# Traverse the structure with #each and do whatever you want, e.g.
collections.each do |collection|

  collection.keylooks.each { # create keylook (aka weblook) }
  collection.studiolooks.each { # create studiolook }

  collection.programs.each do |program|

    program.colors.each { # create options types }

    program.styles.each do |styles|

      styles.each do |style|
        # create product

        style.articles.each do |article|
          # create product variant

          # NOTE: that this will return the article ID blizzard is interested in
          article.legacy_id
        end

        # access prices
        [:chf, :eur].each do |currency|
          # current prices (may be reduced)
          style.sales_price(currency)
          style.purchase_price(currency)

          # original prices (non-reduced)
          style.original_sales_price(currency)
          style.original_purchase_price(currency)

          # find out whether the style is discounted, i.e. sold at a reduced
          # price
          style.discounted?(currency)
        end
      end
    end
  end
end

Development

To install the dependencies and setup config files:

bin/setup

To run the tests:

rake

To see faraday output while running tests:

BLISS_CLIENT_DEBUG=true rake

For an interactive prompt:

bin/console

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fadendaten/bliss-client.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 10 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc