ebisu-rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 521b49e69f7f688cbc7680960e7ada3ef50102c58d7183297c19705689ca5034
4
+ data.tar.gz: b5825249c6f94d85a31b5bddaecd304d5b2f31d90576b04decdba0328180c20a
5
+ SHA512:
6
+ metadata.gz: eaa7652f553b4ca2ed77a42034154593d76774fce9ffbebd99d8a2146fe6d0ea17894fe6615beb598a7f330aa0a63c600a1e67e4622a786dcce0c13eae89d8ff
7
+ data.tar.gz: e68081055d4a44a3ba77890cc0b658f5c038f5b098bc6dfa3bdc2e34b788fb40cf0ee642884daa997d5184cc27e2e8eb7e4465684aaf9e15c7ea1016400f700b
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ebisu.gemspec
6
+ gemspec
@@ -0,0 +1,35 @@
1
+ # Ebisu
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ebisu`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ebisu'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ebisu
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/takafumi.hirata/ebisu.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ebisu"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ebisu/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ebisu-rb"
8
+ spec.version = Ebisu::VERSION
9
+ spec.authors = ["totem3"]
10
+ spec.email = ["ganzheit.com@gmail.com"]
11
+
12
+ spec.summary = %q{yahoo api client}
13
+ spec.description = %q{Ebisu is the yahoo item search api cilent.}
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "faraday"
23
+ spec.add_dependency "faraday_middleware"
24
+ spec.add_dependency "multi_xml"
25
+ spec.add_dependency 'nokogiri'
26
+ spec.add_dependency 'mysql2'
27
+ spec.add_development_dependency "bundler", "~> 1.17"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "pry"
30
+ end
@@ -0,0 +1,16 @@
1
+ require "ebisu/version"
2
+ require "logger"
3
+ require "nokogiri"
4
+ require "multi_xml"
5
+ require "faraday"
6
+ require "faraday_middleware"
7
+ require "ebisu/faraday/request"
8
+ require "ebisu/faraday/connection"
9
+ require "ebisu/apis/category_search"
10
+ require "ebisu/apis/item_search"
11
+ require "ebisu/apis"
12
+ require "ebisu/client"
13
+
14
+ module Ebisu
15
+ class Error < StandardError; end
16
+ end
@@ -0,0 +1,6 @@
1
+ module Ebisu
2
+ module Apis
3
+ include CategorySearch
4
+ include ItemSearch
5
+ end
6
+ end
@@ -0,0 +1,17 @@
1
+ require 'ebisu/models/category_search_response'
2
+ module Ebisu
3
+ module Apis
4
+ module CategorySearch
5
+ # @param [Integer] category_id
6
+ # @param [Hash] options
7
+ # @option options [String] :output 出力形式 ( xml, php, jsonp )
8
+ # @option options [String] :affiliate_type バリューコマースアフィリエイト(vc)
9
+ # @option options [String] :affiliate_id バリューコマースアフィリエイトのID
10
+ # @option options [String] :callback JSONPの場合のコールバック
11
+ def category_search(category_id, options = {})
12
+ options.merge!(category_id: category_id)
13
+ Ebisu::CategorySearchResponse.new get('categorySearch', options)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,52 @@
1
+ require 'ebisu/models/item_search_response'
2
+ module Ebisu
3
+ module Apis
4
+ module ItemSearch
5
+ # @param [Hash] options
6
+ # @option options [String] :query
7
+ # @option options [String] :category_id
8
+ # @option options [String] :product_id
9
+ # @option options [String] :person_id
10
+ # @option options [String] :brand_id
11
+ # @option options [String] :store_id
12
+ # @option options [Integer] :price_from
13
+ # @option options [Integer] :price_to
14
+ # @option options [Float] :affiliate_from
15
+ # @option options [Float] :affiliate_to
16
+ # @option options [Integer] :preorder
17
+ # @option options [Integer] :hits
18
+ # @option options [Integer] :offset
19
+ # @option options [String] :module priceranges/subcategories
20
+ # @option options [Integer] :availability
21
+ # @option options [Integer] :discount
22
+ # @option options [Integer] :shipping (1/2)
23
+ # @option options [String] :payment
24
+ # ウォレット対応カード:yahoowallet
25
+ # クレジットカード:creditcard
26
+ # 商品代引:cod
27
+ # 銀行振込:banktransfer
28
+ # 郵便振替:pmo
29
+ # モバイルSuica:mobilesuica
30
+ # ペイジー:payeasy
31
+ # Yahoo!マネー/預金払い:yahoomoney
32
+ # コンビニ:convenience
33
+ # @option options [String] :license diamond/platinum/gold/silver/bronze/guest
34
+ # @option options [String] :salestart_from
35
+ # @option options [String] :salestart_to
36
+ # @option options [String] :saleend_from
37
+ # @option options [String] :saleend_to
38
+ # @option options [String] :seller (all/store/consumer)
39
+ # @option options [String] :sort (商品価格:price/ストア名:name/おすすめ順:score(デフォルト)/ レビュー数順:review_count)
40
+ # @option options [String] :condition (all/new/used)
41
+ # @option options [String] :output 出力形式 ( xml, php, jsonp )
42
+ # @option options [String] :affiliate_type バリューコマースアフィリエイト(vc)
43
+ # @option options [String] :affiliate_id バリューコマースアフィリエイトのID
44
+ # @option options [String] :callback JSONPの場合のコールバック
45
+ #
46
+ # @return [Ebisu::ItemSearchResponse]
47
+ def item_search(options = {})
48
+ Ebisu::ItemSearchResponse.new(get('itemSearch', options))
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ebisu
4
+ module Configuration
5
+ extend self
6
+
7
+ ATTRIBUTES = %i[
8
+ api_version
9
+ user_agent
10
+ endpoint
11
+ appid
12
+ proxy
13
+ logger
14
+ timeout
15
+ open_timeout
16
+ ].freeze
17
+
18
+ ATTRIBUTES.each do |a|
19
+ attr_accessor a
20
+ end
21
+
22
+ def reset
23
+ self.api_version = 'V1'
24
+ self.endpoint = "https://shopping.yahooapis.jp/ShoppingWebService/#{api_version}/"
25
+ self.user_agent = "YahooShopping Ruby Client/#{Ebisu::VERSION}"
26
+ self.appid = nil
27
+ self.proxy = nil
28
+ self.logger = nil
29
+ self.timeout = 10
30
+ self.open_timeout = 5
31
+ end
32
+ end
33
+ Configuration.reset
34
+
35
+ class Client
36
+ include Ebisu::Faraday::Connection
37
+ include Ebisu::Faraday::Request
38
+ include Ebisu::Apis
39
+
40
+ Configuration::ATTRIBUTES.each do |a|
41
+ attr_accessor a
42
+ end
43
+
44
+ def initialize(options = {})
45
+ Configuration::ATTRIBUTES.each do |key|
46
+ send("#{key}=", options[key] || Configuration.send(key))
47
+ end
48
+ @logger ||= Configuration.logger || ::Logger.new(STDOUT)
49
+ @appid ||= Configuration.appid
50
+ end
51
+
52
+ class << self
53
+ def configure
54
+ block_given? ? yield(Configuration) : Configuration
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,30 @@
1
+ module Ebisu
2
+ module Faraday
3
+ module Connection
4
+ private
5
+
6
+ def connection
7
+ options = {
8
+ headers: { 'Accept' => 'application/xml' }
9
+ }
10
+
11
+ options[:headers]['User-Agent'] = user_agent if user_agent
12
+ options[:proxy] = proxy if proxy
13
+
14
+ request_options = {}
15
+ request_options[:timeout] = timeout if timeout
16
+ request_options[:open_timeout] = open_timeout if open_timeout
17
+ options[:request] = request_options if request_options.any?
18
+
19
+ ::Faraday::Connection.new(endpoint, options) do |connection|
20
+ connection.use ::Faraday::Request::UrlEncoded
21
+ connection.use ::Faraday::Response::RaiseError
22
+ connection.use ::FaradayMiddleware::ParseXml
23
+ require 'logger'
24
+ connection.response :logger, logger if logger
25
+ connection.adapter ::Faraday.default_adapter
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ module Ebisu
2
+ module Faraday
3
+ module Request
4
+ def get(path, options = {})
5
+ request(:get, path, options)
6
+ end
7
+
8
+ def post(path, options = {})
9
+ request(:post, path, options)
10
+ end
11
+
12
+ def put(path, options = {})
13
+ request(:put, path, options)
14
+ end
15
+
16
+ def delete(path, options = {})
17
+ request(:delete, path, options)
18
+ end
19
+
20
+ private
21
+
22
+ def request(method, path, options)
23
+ options = options.merge(appid: appid)
24
+ response = connection.send(method) do |request|
25
+ case method
26
+ when :get, :delete
27
+ request.url(path, options)
28
+ when :post, :put
29
+ request.path = path
30
+ request.body = options unless options.empty?
31
+ end
32
+ request.options.merge!(options.delete(:request)) if options.key?(:request)
33
+ end
34
+ response.body
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module Ebisu
2
+ class Brands
3
+ # @!attribute name
4
+ # @return [String]
5
+ attr_reader :name
6
+
7
+ # @!attribute path
8
+ # @return [String]
9
+ attr_reader :path
10
+ def initialize(brands)
11
+ @name = brands.dig('Name')
12
+ @path = brands.dig('Path', 'Brand')
13
+ end
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,36 @@
1
+ module Ebisu
2
+ class YCategory
3
+ IDAndName = Struct.new(:id, :name)
4
+
5
+ # @!attribute current
6
+ # @return [IDAndName]
7
+ attr_reader :current
8
+ def initialize(category)
9
+ @current = IDAndName.new(
10
+ category.dig('Current', 'Id'),
11
+ category.dig('Current', 'Name')
12
+ )
13
+ end
14
+ end
15
+
16
+ class CategoryDetail
17
+ # @!attribute id
18
+ # @return [Integer]
19
+ attr_reader :id
20
+
21
+ # @!attribute name
22
+ # @return [String]
23
+ attr_reader :name
24
+
25
+ # @!attribute parent_id
26
+ # @return [Integer]
27
+ attr_reader :parent_id
28
+
29
+ def initialize(data)
30
+ @id = data.dig('Id')
31
+ @name = data.dig('Title', 'Short')
32
+ @parent_id = data.dig('ParentId')
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,16 @@
1
+ module Ebisu
2
+ class CategoryIdPath
3
+ # @!attribute path
4
+ # @return [Array[String]]
5
+ attr_reader :path
6
+ def initialize(data)
7
+ category = data['Category']
8
+ @path = case category
9
+ when Array
10
+ category.map { |x| x['Id'] }
11
+ else
12
+ []
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ebisu/models/category'
4
+
5
+ module Ebisu
6
+ class CategorySearchResponse
7
+ def initialize(resp)
8
+ @original_response = resp
9
+ end
10
+
11
+ def [](key)
12
+ @original_response[key]
13
+ end
14
+
15
+ def result_set
16
+ @original_response['ResultSet']
17
+ end
18
+
19
+ def current
20
+ Ebisu::CategoryDetail.new(result_set.dig('Result', 'Categories', 'Current'))
21
+ end
22
+
23
+ # @return [Array<Ebisu::CategoryDetail>]
24
+ def children
25
+ parent_id = current.id
26
+ children = result_set.dig('Result', 'Categories', 'Children', 'Child')
27
+ if children
28
+ children.map do |child|
29
+ child['ParentId'] = parent_id
30
+ Ebisu::CategoryDetail.new(child)
31
+ end
32
+ else
33
+ []
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,24 @@
1
+ module Ebisu
2
+ class ExImage
3
+ # @!attribute url
4
+ # @return [String]
5
+ attr_reader :url
6
+
7
+ # @!attribute width
8
+ # @return [Integer]
9
+ attr_reader :width
10
+
11
+ # @!attribute height
12
+ # @return [Integer]
13
+ attr_reader :height
14
+
15
+ def initialize(image)
16
+ return unless image
17
+
18
+ @url = image.dig('Url')
19
+ @width = image.dig('Width')
20
+ @height = image.dig('Height')
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,22 @@
1
+ module Ebisu
2
+ class Image
3
+ # @!attribute id
4
+ # @return [String]
5
+ attr_reader :id
6
+
7
+ # @!attribute small
8
+ # @return [String]
9
+ attr_reader :small
10
+
11
+ # @!attribute medium
12
+ # @return [String]
13
+ attr_reader :medium
14
+
15
+ def initialize(data)
16
+ @id = data["Id"]
17
+ @small = data["Small"]
18
+ @medium = data["Medium"]
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,139 @@
1
+ module Ebisu
2
+ class Item
3
+ # @!attribute name
4
+ # @return [String]
5
+ attr_reader :name
6
+
7
+ # @!attribute description
8
+ # @return [String]
9
+ attr_reader :description
10
+
11
+ # @!attribute headline
12
+ # @return [String]
13
+ attr_reader :headline
14
+
15
+ # @!attribute url
16
+ # @return [String]
17
+ attr_reader :url
18
+
19
+ # @!attribute [r] availability
20
+ # @return [Ebisu::Item::Availability]
21
+ attr_reader :availability
22
+
23
+ # @!attribute code
24
+ # @return [String]
25
+ attr_reader :code
26
+
27
+ # @!attribute person_id
28
+ # @return [String]
29
+ attr_reader :person_id
30
+
31
+ # @!attribute product_id
32
+ # @return [String]
33
+ attr_reader :product_id
34
+
35
+ # @!attribute image
36
+ # @return [Ebisu::Image]
37
+ attr_reader :image
38
+
39
+ # @!attribute price
40
+ # @return [Ebisu::Price]
41
+ attr_reader :price
42
+
43
+ # @!attribute price_label
44
+ # @return [Ebisu::PriceLabel]
45
+ attr_reader :price_label
46
+
47
+ # @!attribute jan_code
48
+ # @return [String]
49
+ attr_reader :jan_code
50
+
51
+ # @!attribute model
52
+ # @return [String]
53
+ attr_reader :model
54
+
55
+ # @!attribute isbn_code
56
+ # @return [String]
57
+ attr_reader :isbn_code
58
+
59
+ # @!attribute release_date
60
+ # @return [String]
61
+ attr_reader :release_date
62
+
63
+ # @!attribute ex_image
64
+ # @return [Ebisu::ExImage]
65
+ attr_reader :ex_image
66
+
67
+ # @!attribute review
68
+ # @return [Ebisu::Review]
69
+ attr_reader :review
70
+
71
+ # @!attribute point
72
+ # @return [Ebisu::Point]
73
+ attr_reader :point
74
+
75
+ # @!attribute shipping
76
+ # @return [Ebisu::Shipping]
77
+ attr_reader :shipping
78
+
79
+ # @!attribute category
80
+ # @return [Ebisu::YCategory]
81
+ attr_reader :category
82
+
83
+ # @!attribute category_id_path
84
+ # @return [Ebisu::CategoryIdPath]
85
+ attr_reader :category_id_path
86
+
87
+ # @!attribute brands
88
+ # @return [Ebisu::Brands]
89
+ attr_reader :brands
90
+
91
+ # @!attribute store
92
+ # @return [Ebisu::Store]
93
+ attr_reader :store
94
+
95
+ class Availability
96
+ def initialize(v)
97
+ case v
98
+ when 'instock'
99
+ @available = true
100
+ when 'outofstock'
101
+ @available = false
102
+ else
103
+ @available = false
104
+ end
105
+ end
106
+
107
+ # @return [True|False]
108
+ def available?
109
+ @available
110
+ end
111
+ end
112
+
113
+ def initialize(hit)
114
+ @name = hit.dig('Name')
115
+ @description = hit.dig('Description')
116
+ @headline = hit.dig('Headline')
117
+ @url = hit.dig('Url')
118
+ @availability = Availability.new(hit.dig('Availability'))
119
+ @code = hit.dig('Code')
120
+ @person_id = hit.dig('PersonId')
121
+ @product_id = hit.dig('ProductId')
122
+ @price = Ebisu::Price.new(hit.dig('Price'))
123
+ @price_label = Ebisu::PriceLabel.new(hit.dig('PriceLabel'))
124
+ @jan_code = hit.dig('JanCode')
125
+ @model = hit.dig('Model')
126
+ @isbn_code = hit.dig('IsbnCode')
127
+ @release_date = hit.dig('ReleaseDate')
128
+ @image = Ebisu::Image.new(hit.dig('Image'))
129
+ @ex_image = Ebisu::ExImage.new(hit.dig('ExImage'))
130
+ @review = Ebisu::Review.new(hit.dig('Review'))
131
+ @point = Ebisu::Point.new(hit.dig('Point'))
132
+ @shipping = Ebisu::Shipping.new(hit.dig('Shipping'))
133
+ @category = Ebisu::YCategory.new(hit.dig('Category'))
134
+ @category_id_path = Ebisu::CategoryIdPath.new(hit.dig('CategoryIdPath'))
135
+ @brands = Ebisu::Brands.new(hit.dig('Brands'))
136
+ @store = Ebisu::Store.new(hit.dig('Store'))
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ebisu/models/brands'
4
+ require 'ebisu/models/category'
5
+ require 'ebisu/models/category_id_path'
6
+ require 'ebisu/models/ex_image'
7
+ require 'ebisu/models/image'
8
+ require 'ebisu/models/item'
9
+ require 'ebisu/models/payment'
10
+ require 'ebisu/models/payment_method'
11
+ require 'ebisu/models/point'
12
+ require 'ebisu/models/price'
13
+ require 'ebisu/models/price_label'
14
+ require 'ebisu/models/review'
15
+ require 'ebisu/models/shipping'
16
+ require 'ebisu/models/store'
17
+ require 'ebisu/models/store_image'
18
+ require 'ebisu/models/store_ratings'
19
+
20
+ module Ebisu
21
+ # response wrapper
22
+ class ItemSearchResponse
23
+ def initialize(resp)
24
+ @original_response = resp
25
+ end
26
+
27
+ def [](key)
28
+ @original_response[key]
29
+ end
30
+
31
+ def result_set
32
+ @original_response['ResultSet']
33
+ end
34
+
35
+ # @return [Integer] 検索総HIT数
36
+ def total_results_available
37
+ result_set['totalResultsAvailable'].to_i
38
+ end
39
+
40
+ # @return [Integer] 返された値の個数
41
+ def total_results_returned
42
+ result_set['totalResultsReturned'].to_i
43
+ end
44
+
45
+ # @return [Integer] 最初のデータが何個目にあたるか(最初=1)
46
+ def first_result_position
47
+ result_set['firstResultPosition'].to_i
48
+ end
49
+
50
+ # @return [Array<Ebisu::Item>] 検索結果のアイテムのリスト
51
+ def hits
52
+ result_hit = result_set['Result']['Hit']
53
+ case result_hit
54
+ when Array
55
+ result_hit.map{|hit| Ebisu::Item.new(hit)}
56
+ when Hash
57
+ # 結果がないとき
58
+ if result_hit['index'].to_i == 0
59
+ [].map{|hit| Ebisu::Item.new(hit)}
60
+
61
+ # 結果が1件だけのとき
62
+ else
63
+ [result_hit].map{|hit| Ebisu::Item.new(hit)}
64
+ end
65
+ when NilClass
66
+ [].map{|hit| Ebisu::Item.new(hit)}
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,18 @@
1
+ module Ebisu
2
+ class Payment
3
+ # @!attribute method
4
+ # @return [Array[PaymentMethod]]
5
+ attr_reader :method
6
+ def initialize(data)
7
+ @method = case data['Method']
8
+ when Array
9
+ data['Method'].map { |x| PaymentMethod.new(x) }
10
+ when NilClass
11
+ []
12
+ else
13
+ [PaymentMethod.new(data)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,16 @@
1
+ module Ebisu
2
+ class PaymentMethod
3
+ # @!attribute code
4
+ # @return [Integer]
5
+ attr_reader :code
6
+
7
+ # @!attribute name
8
+ # @return [String]
9
+ attr_reader :name
10
+ def initialize(data)
11
+ @code = data.dig('Code').to_i
12
+ @name = data.dig('Name')
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,24 @@
1
+ module Ebisu
2
+ class Point
3
+ # @!attribute amount
4
+ # @return [Integer]
5
+ attr_reader :amount
6
+ # @!attribute times
7
+ # @return [Integer]
8
+ attr_reader :times
9
+ # @!attribute premium_amount
10
+ # @return [Integer]
11
+ attr_reader :premium_amount
12
+ # @!attribute premium_times
13
+ # @return [Integer]
14
+ attr_reader :premium_times
15
+
16
+ def initialize(point)
17
+ @amount = point.dig('Amount').to_i
18
+ @times = point.dig('Times').to_i
19
+ @premium_amount = point.dig('PremiumAmount').to_i
20
+ @premium_times = point.dig('PremiumTimes').to_i
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ module Ebisu
2
+ class Price
3
+ # @!attribute value
4
+ # @return [Integer]
5
+ attr_reader :value
6
+
7
+ # @!attribute currency
8
+ # @return [String]
9
+ attr_reader :currency
10
+
11
+ def initialize(price)
12
+ case price
13
+ when Hash
14
+ @value = Integer(price['__content__'])
15
+ @currency = price['currency']
16
+ when String
17
+ @value = Integer(price)
18
+ @currency = 'JPY'
19
+ when Integer
20
+ @value = price
21
+ @currency = 'JPY'
22
+ else
23
+ raise "assertion failed. invalid price response value: #{price}"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,47 @@
1
+ module Ebisu
2
+ class PriceLabel
3
+ # @!attribute is_inclusive
4
+ # @return [True|False]
5
+ attr_reader :is_inclusive
6
+
7
+ # @!attribute fixed_price
8
+ # @return [Integer|Nil]
9
+ attr_reader :fixed_price
10
+
11
+ # @!attribute default_price
12
+ # @return [Integer|Nil]
13
+ attr_reader :default_price
14
+
15
+ # @!attribute sale_price
16
+ # @return [Integer|Nil]
17
+ attr_reader :sale_price
18
+
19
+ # @!attribute base_fixed_price
20
+ # @return [Integer|Nil]
21
+ attr_reader :base_fixed_price
22
+
23
+ # @!attribute base_sale_price
24
+ # @return [Integer|Nil]
25
+ attr_reader :base_sale_price
26
+
27
+ # @!attribute period_start
28
+ # @return [String]
29
+ attr_reader :period_start
30
+
31
+ # @!attribute period_end
32
+ # @return [String]
33
+ attr_reader :period_end
34
+
35
+ def initialize(price_label)
36
+ @is_inclusive = price_label['taxIncluded'] == 'true'
37
+ @fixed_price = price_label['FixedPrice']
38
+ @default_price = price_label['DefaultPrice']
39
+ @sale_price = price_label['SalePrice']
40
+ @base_fixed_price = price_label['BaseFixedPrice']
41
+ @base_sale_price = price_label['BaseSalePrice']
42
+ @period_start = price_label['PeriodStart']
43
+ @period_end = price_label['PeriodEnd']
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,22 @@
1
+ module Ebisu
2
+ class Review
3
+ # @!attribute rate
4
+ # @return [Float]
5
+ attr_reader :rate
6
+
7
+ # @!attribute count
8
+ # @return [Integer]
9
+ attr_reader :count
10
+
11
+ # @!attribute url
12
+ # @return [String]
13
+ attr_reader :url
14
+
15
+ def initialize(review)
16
+ @rate = review.dig('Rate').to_f
17
+ @count = review.dig('Count').to_i
18
+ @url = review.dig('Url')
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,17 @@
1
+ module Ebisu
2
+ class Shipping
3
+ # @!attribute code
4
+ # @return [String]
5
+ attr_reader :code
6
+
7
+ # @!attribute name
8
+ # @return [String]
9
+ attr_reader :name
10
+
11
+ def initialize(shipping)
12
+ @code = shipping.dig('Code')
13
+ @name = shipping.dig('Name')
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,26 @@
1
+ module Ebisu
2
+ class Store
3
+ # @!attribute name
4
+ # @return [String]
5
+ attr_reader :name
6
+
7
+ # @!attribute payment
8
+ # @return [Ebisu::Payment]
9
+ attr_reader :payment
10
+
11
+ # @!attribute is_best_store
12
+ # @return [True|False]
13
+ attr_reader :is_best_store
14
+
15
+ # @!attribute ratings
16
+ # @return [Ebisu::StoreRatings]
17
+ attr_reader :ratings
18
+ def initialize(data)
19
+ @name = data.dig('Name')
20
+ @payment = Ebisu::Payment.new(data.dig('Payment'))
21
+ @is_best_store = data.dig('IsBestStore') == 'true'
22
+ @ratings = Ebisu::StoreRatings.new(data.dig('Ratings'))
23
+ @image = Ebisu::StoreImage.new(data.dig('Image'))
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ module Ebisu
2
+ class StoreImage
3
+ # @!attribute id
4
+ # @return [String]
5
+ attr_reader :id
6
+
7
+ # @!attribute medium
8
+ # @return [String]
9
+ attr_reader :medium
10
+ def initialize(data)
11
+ @id = data.dig('Id')
12
+ @medium = data.dig('Medium')
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,16 @@
1
+ module Ebisu
2
+ class StoreRatings
3
+ # @!attribute rate
4
+ # @return [Float]
5
+ attr_reader :rate
6
+
7
+ # @!attribute count
8
+ # @return [Integer]
9
+ attr_reader :count
10
+ def initialize(data)
11
+ @rate = data.dig('Rate').to_f
12
+ @count = data.dig('Count').to_i
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,3 @@
1
+ module Ebisu
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ebisu-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - totem3
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_xml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mysql2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.17'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.17'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Ebisu is the yahoo item search api cilent.
126
+ email:
127
+ - ganzheit.com@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - README.md
135
+ - Rakefile
136
+ - bin/console
137
+ - bin/setup
138
+ - ebisu.gemspec
139
+ - lib/ebisu.rb
140
+ - lib/ebisu/apis.rb
141
+ - lib/ebisu/apis/category_search.rb
142
+ - lib/ebisu/apis/item_search.rb
143
+ - lib/ebisu/client.rb
144
+ - lib/ebisu/faraday/connection.rb
145
+ - lib/ebisu/faraday/request.rb
146
+ - lib/ebisu/models/brands.rb
147
+ - lib/ebisu/models/category.rb
148
+ - lib/ebisu/models/category_id_path.rb
149
+ - lib/ebisu/models/category_search_response.rb
150
+ - lib/ebisu/models/ex_image.rb
151
+ - lib/ebisu/models/image.rb
152
+ - lib/ebisu/models/item.rb
153
+ - lib/ebisu/models/item_search_response.rb
154
+ - lib/ebisu/models/payment.rb
155
+ - lib/ebisu/models/payment_method.rb
156
+ - lib/ebisu/models/point.rb
157
+ - lib/ebisu/models/price.rb
158
+ - lib/ebisu/models/price_label.rb
159
+ - lib/ebisu/models/review.rb
160
+ - lib/ebisu/models/shipping.rb
161
+ - lib/ebisu/models/store.rb
162
+ - lib/ebisu/models/store_image.rb
163
+ - lib/ebisu/models/store_ratings.rb
164
+ - lib/ebisu/version.rb
165
+ homepage:
166
+ licenses: []
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubygems_version: 3.0.3
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: yahoo api client
187
+ test_files: []