0.0
No commit activity in last 3 years
No release in over 3 years
Ruby 7net shopping API using Nokogiri.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
>= 0
= 1.11.0

Runtime

 Project Readme

Sevennet::Api

Gem Version Ruby 7netshopping API using Nokogiri. Uses Response and Element wrapper classes for easy access to the REST API XML output.

Installation

Add this line to your application's Gemfile:

gem 'sevennet-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sevennet-api

Usage

require 'sevennet/api'


Sevennet::Api.configure do |options|
  options[:ApiUserId] = 'your api user id'
  options[:APISecretKey] = 'your api secret key'
end

# GetShoppingCategory
res = Sevennet::Api.get_shopping_category('') # root category
res = Sevennet::Api.get_shopping_category('books') # books category
res.categories.each do |category|
  children = category.get_elements('ChildCategory')
  children.each do |child|
    code = child.get('CategoryCode')
    ...
  end
end

# SearchProduct
res = Sevennet::Api.search_product('ruby', {:ShoppingSortOrder => 'reviews'}) # keyword match
res = Sevennet::Api.search_product('', {:CategoryCode = 'books'}) # category match
res = Sevennet::Api.search_product('ruby', {:CategoryCode = 'books'}) # keyword and category match
res.products.each do |product|
  code = product.get('ProductCode')
  ...
end

# SearchRanking
res = Sevennet::Api.search_ranking('books', {:GenerationCond => 10, :SexCond => 'male'})
res.products.each do |product|
  code = product.get('ProductCode')
  ...
end

# SearchProductReview
res = Sevennet::Api.search_product_review('2110150300') # ProductCode
res = Sevennet::Api.search_product_review('21-101-503-00',:type => 'ProductStandardCode') # ISBN JAN etc
res.reviews.each do |review|
  title = review.get('CommentTitle')
  ...
end

# GetSpcCategory
res = Sevennet::Api.get_spc_category('') # root category
res = Sevennet::Api.get_spc_category('home') # home category
res.categories.each do |category|
  children = category.get_elements('ChildCategory')
  next if children.nil?
  children.each do |child|
    code = child.get('CategoryCode')
    ...
  end
end

# SearchSpcShop
res = Sevennet::Api.search_spc_shop('', {:SpcSortOrder => 'name') # all
res = Sevennet::Api.search_spc_shop('ruby', {:SpcSortOrder => 'name') # keyword match
res.shops.each do |shop|
  id = shop.get('SpcShopId')
  ...
end

# some common response object methods
res.has_error?            # return true if there is an error
res.error                 # return error message if there is any
res.total_amount          # return total results

# Extend Sevennet::Api, replace 'other_operation' with the appropriate name
module Sevennet
  class Api
    def self.other_operation(item_id, opts={})
      opts[:operation] = '[other valid operation supported by 7netshopping API]'

      # setting default option value
      opts[:item_id] = item_id

      self.send_request(opts)
    end
  end
end

Sevennet::Api.other_operation('[item_id]', :param1 => 'abc', :param2 => 'xyz')

Refer to 7netshopping API documentation for more information on other valid operations, request parameters and the XML response output: http://www.7netshopping.jp/

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request