=begin #カラーミーショップ API ## カラーミーショップ API [カラーミーショップ](https://shop-pro.jp) APIでは、受注の検索や商品情報の更新を行うことができます。 ## 利用手順 はじめに、カラーミーデベロッパーアカウントを用意します。[デベロッパー登録ページ](https://api.shop-pro.jp/developers/sign_up)から登録してください。 次に、[登録ページ](https://api.shop-pro.jp/oauth/applications/new)からアプリケーション登録を行ってください。 スマートフォンのWebViewを利用する場合は、リダイレクトURLに`urn:ietf:wg:oauth:2.0:oob`を入力してください。 その後、カラーミーショップアカウントの認証ページを開きます。認証ページのURLは、`https://api.shop-pro.jp/oauth/authorize`に必要なパラメータをつけたものです。 |パラメータ名|値| |---|---| |`client_id`|アプリケーション詳細画面で確認できるクライアントID| |`response_type`|\"code\"という文字列| |`scope`| 別表参照| |`redirect_url`|アプリケーション登録時に入力したリダイレクトURL| `scope`は、以下のうち、アプリケーションが利用したい機能をスペース区切りで指定してください。 |スコープ|機能| |---|---| |`read_products`|商品データの参照| |`write_products`|在庫データの更新| |`read_sales`|受注・顧客データの参照| |`write_sales`|受注データの更新| 以下のようなURLとなります。 ``` https://api.shop-pro.jp/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=code&scope=read_products%20write_products ``` 初めてこのページを訪れる場合は、カラーミーショップアカウントのIDとパスワードの入力を求められます。 承認ボタンを押すと、このアプリケーションがショップのデータにアクセスすることが許可され、リダイレクトURLへリダイレクトされます。 承認された場合は、`code`というクエリパラメータに認可コードが付与されます。承認がキャンセルされた、またはエラーが起きた場合は、 `error`パラメータにエラーの内容を表す文字列が与えられます。 アプリケーション登録時のリダイレクトURLに`urn:ietf:wg:oauth:2.0:oob`を指定した場合は、以下のようなURLにリダイレクトされます。 末尾のパスが認可コードになっています。 ``` https://api.shop-pro.jp/oauth/authorize/AUTH_CODE ``` 認可コードの有効期限は発行から10分間です。 最後に、認可コードとアクセストークンを交換します。以下のパラメータを付けて、`https://api.shop-pro.jp/oauth/token`へリクエストを送ります。 |パラメータ名|値| |---|---| |`client_id`|アプリケーション詳細画面に表示されているクライアントID| |`client_secret`|アプリケーション詳細画面に表示されているクライアントシークレット| |`code`|取得した認可コード| |`grant_type`|\"authorization_code\"という文字列| |`redirect_uri`|アプリケーション登録時に入力したリダイレクトURL| ```console # curl での例 $ curl -X POST \\ -d'client_id=CLIENT_ID' \\ -d'client_secret=CLIENT_SECRET' \\ -d'code=CODE' \\ -d'grant_type=authorization_code' \\ -d'redirect_uri=REDIRECT_URI' \\ 'https://api.shop-pro.jp/oauth/token' ``` リクエストが成功すると、以下のようなJSONが返ってきます。 ```json { \"access_token\": \"d461ab8XXXXXXXXXXXXXXXXXXXXXXXXX\", \"token_type\": \"bearer\", \"scope\": \"read_products write_products\" } ``` アクセストークンに有効期限はありませんが、許可済みアプリケーション一覧画面から失効させることができます。なお、同じ認可コードをアクセストークンに交換できるのは1度だけです。 取得したアクセストークンは、Authorizationヘッダに入れて使用します。以下にショップ情報を取得する際の例を示します。 ```console # curlの例 $ curl -H 'Authorization: Bearer d461ab8XXXXXXXXXXXXXXXXXXXXXXXXX' https://api.shop-pro.jp/v1/shop.json ``` ## エラー カラーミーショップAPI v1では - エラーコード - エラーメッセージ - ステータスコード の配列でエラーを表現します。以下に例を示します。 ```json { \"errors\": [ { \"code\": 404100, \"message\": \"レコードが見つかりませんでした。\", \"status\": 404 } ] } ``` OpenAPI spec version: 1.0.0 Generated by: https://openapi-generator.tech OpenAPI Generator version: 3.2.0-SNAPSHOT =end require 'date' module ColorMeShop class Sale # 売上ID attr_accessor :id # ショップアカウントID attr_accessor :account_id # 受注日時 attr_accessor :make_date # 受注更新日時 attr_accessor :update_date # 備考 attr_accessor :memo # 使用された決済方法ID attr_accessor :payment_id # モバイルからの注文であるか否か attr_accessor :mobile # 入金済みであるか否か attr_accessor :paid # 発送済みである否か attr_accessor :delivered # キャンセル済みであるか否か attr_accessor :canceled # 受注メールの送信状態 - `not_yet`: 未送信 - `sent`: 送信済み - `pass`: 送信しない attr_accessor :accepted_mail_state # 入金メールの送信状態 - `not_yet`: 未送信 - `sent`: 送信済み - `pass`: 送信しない attr_accessor :paid_mail_state # 発送メールの送信状態 - `not_yet`: 未送信 - `sent`: 送信済み - `pass`: 送信しない attr_accessor :delivered_mail_state # 受注メールの送信日時 attr_accessor :accepted_mail_sent_date # 入金メールの送信日時 attr_accessor :paid_mail_sent_date # 発送メールの送信日時 attr_accessor :delivered_mail_sent_date # ショップポイント付与状態 - `assumed`: 仮付与 - `fixed`: 確定済み - `canceled`: キャンセル済み attr_accessor :point_state # GMOポイント付与状態 - `assumed`: 仮付与 - `fixed`: 確定済み - `canceled`: キャンセル済み attr_accessor :gmo_point_state # Yahooポイント付与状態 - `assumed`: 仮付与 - `fixed`: 確定済み - `canceled`: キャンセル済み attr_accessor :yahoo_point_state # 商品の合計金額 attr_accessor :product_total_price # 配送料 attr_accessor :delivery_total_charge # 決済手数料 attr_accessor :fee # 商品合計金額に対する消費税 attr_accessor :tax # 熨斗料金 attr_accessor :noshi_total_charge # メッセージカード料金 attr_accessor :card_total_charge # ラッピング料金 attr_accessor :wrapping_total_charge # ショップポイントによる割引額 attr_accessor :point_discount # GMOポイントによる割引額 attr_accessor :gmo_point_discount # その他、クーポン等による割引額 attr_accessor :other_discount # その他割引の名称 attr_accessor :other_discount_name # 注文総額 attr_accessor :total_price # 付与されたショップポイント数 attr_accessor :granted_points # 使用されたショップポイント数 attr_accessor :use_points # 付与されたGMOポイント数 attr_accessor :granted_gmo_points # 使用されたGMOポイント数 attr_accessor :use_gmo_points # 付与されたYahooポイント数 attr_accessor :granted_yahoo_points # 使用されたYahooポイント数 attr_accessor :use_yahoo_points attr_accessor :customer attr_accessor :details attr_accessor :sale_deliveries class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'id' => :'id', :'account_id' => :'account_id', :'make_date' => :'make_date', :'update_date' => :'update_date', :'memo' => :'memo', :'payment_id' => :'payment_id', :'mobile' => :'mobile', :'paid' => :'paid', :'delivered' => :'delivered', :'canceled' => :'canceled', :'accepted_mail_state' => :'accepted_mail_state', :'paid_mail_state' => :'paid_mail_state', :'delivered_mail_state' => :'delivered_mail_state', :'accepted_mail_sent_date' => :'accepted_mail_sent_date', :'paid_mail_sent_date' => :'paid_mail_sent_date', :'delivered_mail_sent_date' => :'delivered_mail_sent_date', :'point_state' => :'point_state', :'gmo_point_state' => :'gmo_point_state', :'yahoo_point_state' => :'yahoo_point_state', :'product_total_price' => :'product_total_price', :'delivery_total_charge' => :'delivery_total_charge', :'fee' => :'fee', :'tax' => :'tax', :'noshi_total_charge' => :'noshi_total_charge', :'card_total_charge' => :'card_total_charge', :'wrapping_total_charge' => :'wrapping_total_charge', :'point_discount' => :'point_discount', :'gmo_point_discount' => :'gmo_point_discount', :'other_discount' => :'other_discount', :'other_discount_name' => :'other_discount_name', :'total_price' => :'total_price', :'granted_points' => :'granted_points', :'use_points' => :'use_points', :'granted_gmo_points' => :'granted_gmo_points', :'use_gmo_points' => :'use_gmo_points', :'granted_yahoo_points' => :'granted_yahoo_points', :'use_yahoo_points' => :'use_yahoo_points', :'customer' => :'customer', :'details' => :'details', :'sale_deliveries' => :'sale_deliveries' } end # Attribute type mapping. def self.openapi_types { :'id' => :'Integer', :'account_id' => :'String', :'make_date' => :'Integer', :'update_date' => :'Integer', :'memo' => :'String', :'payment_id' => :'Integer', :'mobile' => :'BOOLEAN', :'paid' => :'BOOLEAN', :'delivered' => :'BOOLEAN', :'canceled' => :'BOOLEAN', :'accepted_mail_state' => :'String', :'paid_mail_state' => :'String', :'delivered_mail_state' => :'String', :'accepted_mail_sent_date' => :'Integer', :'paid_mail_sent_date' => :'Integer', :'delivered_mail_sent_date' => :'Integer', :'point_state' => :'String', :'gmo_point_state' => :'String', :'yahoo_point_state' => :'String', :'product_total_price' => :'Integer', :'delivery_total_charge' => :'Integer', :'fee' => :'Integer', :'tax' => :'Integer', :'noshi_total_charge' => :'Integer', :'card_total_charge' => :'Integer', :'wrapping_total_charge' => :'Integer', :'point_discount' => :'Integer', :'gmo_point_discount' => :'Integer', :'other_discount' => :'Integer', :'other_discount_name' => :'String', :'total_price' => :'Integer', :'granted_points' => :'Integer', :'use_points' => :'Integer', :'granted_gmo_points' => :'Integer', :'use_gmo_points' => :'Integer', :'granted_yahoo_points' => :'Integer', :'use_yahoo_points' => :'Integer', :'customer' => :'Customer', :'details' => :'Array', :'sale_deliveries' => :'Array' } end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'account_id') self.account_id = attributes[:'account_id'] end if attributes.has_key?(:'make_date') self.make_date = attributes[:'make_date'] end if attributes.has_key?(:'update_date') self.update_date = attributes[:'update_date'] end if attributes.has_key?(:'memo') self.memo = attributes[:'memo'] end if attributes.has_key?(:'payment_id') self.payment_id = attributes[:'payment_id'] end if attributes.has_key?(:'mobile') self.mobile = attributes[:'mobile'] end if attributes.has_key?(:'paid') self.paid = attributes[:'paid'] end if attributes.has_key?(:'delivered') self.delivered = attributes[:'delivered'] end if attributes.has_key?(:'canceled') self.canceled = attributes[:'canceled'] end if attributes.has_key?(:'accepted_mail_state') self.accepted_mail_state = attributes[:'accepted_mail_state'] end if attributes.has_key?(:'paid_mail_state') self.paid_mail_state = attributes[:'paid_mail_state'] end if attributes.has_key?(:'delivered_mail_state') self.delivered_mail_state = attributes[:'delivered_mail_state'] end if attributes.has_key?(:'accepted_mail_sent_date') self.accepted_mail_sent_date = attributes[:'accepted_mail_sent_date'] end if attributes.has_key?(:'paid_mail_sent_date') self.paid_mail_sent_date = attributes[:'paid_mail_sent_date'] end if attributes.has_key?(:'delivered_mail_sent_date') self.delivered_mail_sent_date = attributes[:'delivered_mail_sent_date'] end if attributes.has_key?(:'point_state') self.point_state = attributes[:'point_state'] end if attributes.has_key?(:'gmo_point_state') self.gmo_point_state = attributes[:'gmo_point_state'] end if attributes.has_key?(:'yahoo_point_state') self.yahoo_point_state = attributes[:'yahoo_point_state'] end if attributes.has_key?(:'product_total_price') self.product_total_price = attributes[:'product_total_price'] end if attributes.has_key?(:'delivery_total_charge') self.delivery_total_charge = attributes[:'delivery_total_charge'] end if attributes.has_key?(:'fee') self.fee = attributes[:'fee'] end if attributes.has_key?(:'tax') self.tax = attributes[:'tax'] end if attributes.has_key?(:'noshi_total_charge') self.noshi_total_charge = attributes[:'noshi_total_charge'] end if attributes.has_key?(:'card_total_charge') self.card_total_charge = attributes[:'card_total_charge'] end if attributes.has_key?(:'wrapping_total_charge') self.wrapping_total_charge = attributes[:'wrapping_total_charge'] end if attributes.has_key?(:'point_discount') self.point_discount = attributes[:'point_discount'] end if attributes.has_key?(:'gmo_point_discount') self.gmo_point_discount = attributes[:'gmo_point_discount'] end if attributes.has_key?(:'other_discount') self.other_discount = attributes[:'other_discount'] end if attributes.has_key?(:'other_discount_name') self.other_discount_name = attributes[:'other_discount_name'] end if attributes.has_key?(:'total_price') self.total_price = attributes[:'total_price'] end if attributes.has_key?(:'granted_points') self.granted_points = attributes[:'granted_points'] end if attributes.has_key?(:'use_points') self.use_points = attributes[:'use_points'] end if attributes.has_key?(:'granted_gmo_points') self.granted_gmo_points = attributes[:'granted_gmo_points'] end if attributes.has_key?(:'use_gmo_points') self.use_gmo_points = attributes[:'use_gmo_points'] end if attributes.has_key?(:'granted_yahoo_points') self.granted_yahoo_points = attributes[:'granted_yahoo_points'] end if attributes.has_key?(:'use_yahoo_points') self.use_yahoo_points = attributes[:'use_yahoo_points'] end if attributes.has_key?(:'customer') self.customer = attributes[:'customer'] end if attributes.has_key?(:'details') if (value = attributes[:'details']).is_a?(Array) self.details = value end end if attributes.has_key?(:'sale_deliveries') if (value = attributes[:'sale_deliveries']).is_a?(Array) self.sale_deliveries = value end end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? accepted_mail_state_validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) return false unless accepted_mail_state_validator.valid?(@accepted_mail_state) paid_mail_state_validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) return false unless paid_mail_state_validator.valid?(@paid_mail_state) delivered_mail_state_validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) return false unless delivered_mail_state_validator.valid?(@delivered_mail_state) point_state_validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) return false unless point_state_validator.valid?(@point_state) gmo_point_state_validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) return false unless gmo_point_state_validator.valid?(@gmo_point_state) yahoo_point_state_validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) return false unless yahoo_point_state_validator.valid?(@yahoo_point_state) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] accepted_mail_state Object to be assigned def accepted_mail_state=(accepted_mail_state) validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) unless validator.valid?(accepted_mail_state) fail ArgumentError, 'invalid value for "accepted_mail_state", must be one of #{validator.allowable_values}.' end @accepted_mail_state = accepted_mail_state end # Custom attribute writer method checking allowed values (enum). # @param [Object] paid_mail_state Object to be assigned def paid_mail_state=(paid_mail_state) validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) unless validator.valid?(paid_mail_state) fail ArgumentError, 'invalid value for "paid_mail_state", must be one of #{validator.allowable_values}.' end @paid_mail_state = paid_mail_state end # Custom attribute writer method checking allowed values (enum). # @param [Object] delivered_mail_state Object to be assigned def delivered_mail_state=(delivered_mail_state) validator = EnumAttributeValidator.new('String', ['not_yet', 'sent', 'pass']) unless validator.valid?(delivered_mail_state) fail ArgumentError, 'invalid value for "delivered_mail_state", must be one of #{validator.allowable_values}.' end @delivered_mail_state = delivered_mail_state end # Custom attribute writer method checking allowed values (enum). # @param [Object] point_state Object to be assigned def point_state=(point_state) validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) unless validator.valid?(point_state) fail ArgumentError, 'invalid value for "point_state", must be one of #{validator.allowable_values}.' end @point_state = point_state end # Custom attribute writer method checking allowed values (enum). # @param [Object] gmo_point_state Object to be assigned def gmo_point_state=(gmo_point_state) validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) unless validator.valid?(gmo_point_state) fail ArgumentError, 'invalid value for "gmo_point_state", must be one of #{validator.allowable_values}.' end @gmo_point_state = gmo_point_state end # Custom attribute writer method checking allowed values (enum). # @param [Object] yahoo_point_state Object to be assigned def yahoo_point_state=(yahoo_point_state) validator = EnumAttributeValidator.new('String', ['assumed', 'fixed', 'canceled']) unless validator.valid?(yahoo_point_state) fail ArgumentError, 'invalid value for "yahoo_point_state", must be one of #{validator.allowable_values}.' end @yahoo_point_state = yahoo_point_state end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && account_id == o.account_id && make_date == o.make_date && update_date == o.update_date && memo == o.memo && payment_id == o.payment_id && mobile == o.mobile && paid == o.paid && delivered == o.delivered && canceled == o.canceled && accepted_mail_state == o.accepted_mail_state && paid_mail_state == o.paid_mail_state && delivered_mail_state == o.delivered_mail_state && accepted_mail_sent_date == o.accepted_mail_sent_date && paid_mail_sent_date == o.paid_mail_sent_date && delivered_mail_sent_date == o.delivered_mail_sent_date && point_state == o.point_state && gmo_point_state == o.gmo_point_state && yahoo_point_state == o.yahoo_point_state && product_total_price == o.product_total_price && delivery_total_charge == o.delivery_total_charge && fee == o.fee && tax == o.tax && noshi_total_charge == o.noshi_total_charge && card_total_charge == o.card_total_charge && wrapping_total_charge == o.wrapping_total_charge && point_discount == o.point_discount && gmo_point_discount == o.gmo_point_discount && other_discount == o.other_discount && other_discount_name == o.other_discount_name && total_price == o.total_price && granted_points == o.granted_points && use_points == o.use_points && granted_gmo_points == o.granted_gmo_points && use_gmo_points == o.use_gmo_points && granted_yahoo_points == o.granted_yahoo_points && use_yahoo_points == o.use_yahoo_points && customer == o.customer && details == o.details && sale_deliveries == o.sale_deliveries end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash [id, account_id, make_date, update_date, memo, payment_id, mobile, paid, delivered, canceled, accepted_mail_state, paid_mail_state, delivered_mail_state, accepted_mail_sent_date, paid_mail_sent_date, delivered_mail_sent_date, point_state, gmo_point_state, yahoo_point_state, product_total_price, delivery_total_charge, fee, tax, noshi_total_charge, card_total_charge, wrapping_total_charge, point_discount, gmo_point_discount, other_discount, other_discount_name, total_price, granted_points, use_points, granted_gmo_points, use_gmo_points, granted_yahoo_points, use_yahoo_points, customer, details, sale_deliveries].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = ColorMeShop.const_get(type).new temp_model.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end