lazada_dino 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.DS_Store +0 -0
 - data/.gitignore +8 -0
 - data/CODE_OF_CONDUCT.md +74 -0
 - data/Gemfile +6 -0
 - data/Gemfile.lock +52 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +120 -0
 - data/Rakefile +2 -0
 - data/bin/console +14 -0
 - data/bin/setup +8 -0
 - data/lazada_dino.gemspec +39 -0
 - data/lib/lazada_dino.rb +3 -0
 - data/lib/lazada_dino/.DS_Store +0 -0
 - data/lib/lazada_dino/api/brand.rb +18 -0
 - data/lib/lazada_dino/api/category.rb +21 -0
 - data/lib/lazada_dino/api/feed.rb +19 -0
 - data/lib/lazada_dino/api/image.rb +45 -0
 - data/lib/lazada_dino/api/order.rb +48 -0
 - data/lib/lazada_dino/api/product.rb +134 -0
 - data/lib/lazada_dino/api/response.rb +62 -0
 - data/lib/lazada_dino/api/shipment.rb +35 -0
 - data/lib/lazada_dino/client.rb +91 -0
 - data/lib/lazada_dino/exceptions/lazada.rb +42 -0
 - data/lib/lazada_dino/version.rb +3 -0
 - metadata +166 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 207f04a5b7ca56426b7701a5645c714f7a6367e4182260beb13b95d38a66ad44
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c7519eb8b684e143a57d76e634f5796aa0468ef5171d43d690d1f4db1b0eba70
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 999876f3f30d2ac589bd8863a01baaba68a5f0e16fd0ddfcc552bd077bbf3ba4bd8fa0d2508f75b37e740fe13d3d68575818bbbe177cf7a4eb28b7ce494277d5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: aebacd54d6feff4935e9f30183313bd6b96f6805fe55a8b703116b5c0686268fffbebd1b57d78d4617e1ae55bfadec63401fae7d1ee6ac095e5b8212aac0287b
         
     | 
    
        data/.DS_Store
    ADDED
    
    | 
         Binary file 
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/CODE_OF_CONDUCT.md
    ADDED
    
    | 
         @@ -0,0 +1,74 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Contributor Covenant Code of Conduct
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ## Our Pledge
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            In the interest of fostering an open and welcoming environment, we as
         
     | 
| 
      
 6 
     | 
    
         
            +
            contributors and maintainers pledge to making participation in our project and
         
     | 
| 
      
 7 
     | 
    
         
            +
            our community a harassment-free experience for everyone, regardless of age, body
         
     | 
| 
      
 8 
     | 
    
         
            +
            size, disability, ethnicity, gender identity and expression, level of experience,
         
     | 
| 
      
 9 
     | 
    
         
            +
            nationality, personal appearance, race, religion, or sexual identity and
         
     | 
| 
      
 10 
     | 
    
         
            +
            orientation.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ## Our Standards
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Examples of behavior that contributes to creating a positive environment
         
     | 
| 
      
 15 
     | 
    
         
            +
            include:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            * Using welcoming and inclusive language
         
     | 
| 
      
 18 
     | 
    
         
            +
            * Being respectful of differing viewpoints and experiences
         
     | 
| 
      
 19 
     | 
    
         
            +
            * Gracefully accepting constructive criticism
         
     | 
| 
      
 20 
     | 
    
         
            +
            * Focusing on what is best for the community
         
     | 
| 
      
 21 
     | 
    
         
            +
            * Showing empathy towards other community members
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Examples of unacceptable behavior by participants include:
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            * The use of sexualized language or imagery and unwelcome sexual attention or
         
     | 
| 
      
 26 
     | 
    
         
            +
            advances
         
     | 
| 
      
 27 
     | 
    
         
            +
            * Trolling, insulting/derogatory comments, and personal or political attacks
         
     | 
| 
      
 28 
     | 
    
         
            +
            * Public or private harassment
         
     | 
| 
      
 29 
     | 
    
         
            +
            * Publishing others' private information, such as a physical or electronic
         
     | 
| 
      
 30 
     | 
    
         
            +
              address, without explicit permission
         
     | 
| 
      
 31 
     | 
    
         
            +
            * Other conduct which could reasonably be considered inappropriate in a
         
     | 
| 
      
 32 
     | 
    
         
            +
              professional setting
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ## Our Responsibilities
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            Project maintainers are responsible for clarifying the standards of acceptable
         
     | 
| 
      
 37 
     | 
    
         
            +
            behavior and are expected to take appropriate and fair corrective action in
         
     | 
| 
      
 38 
     | 
    
         
            +
            response to any instances of unacceptable behavior.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            Project maintainers have the right and responsibility to remove, edit, or
         
     | 
| 
      
 41 
     | 
    
         
            +
            reject comments, commits, code, wiki edits, issues, and other contributions
         
     | 
| 
      
 42 
     | 
    
         
            +
            that are not aligned to this Code of Conduct, or to ban temporarily or
         
     | 
| 
      
 43 
     | 
    
         
            +
            permanently any contributor for other behaviors that they deem inappropriate,
         
     | 
| 
      
 44 
     | 
    
         
            +
            threatening, offensive, or harmful.
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            ## Scope
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            This Code of Conduct applies both within project spaces and in public spaces
         
     | 
| 
      
 49 
     | 
    
         
            +
            when an individual is representing the project or its community. Examples of
         
     | 
| 
      
 50 
     | 
    
         
            +
            representing a project or community include using an official project e-mail
         
     | 
| 
      
 51 
     | 
    
         
            +
            address, posting via an official social media account, or acting as an appointed
         
     | 
| 
      
 52 
     | 
    
         
            +
            representative at an online or offline event. Representation of a project may be
         
     | 
| 
      
 53 
     | 
    
         
            +
            further defined and clarified by project maintainers.
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            ## Enforcement
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            Instances of abusive, harassing, or otherwise unacceptable behavior may be
         
     | 
| 
      
 58 
     | 
    
         
            +
            reported by contacting the project team at cyusheng93@gmail.com. All
         
     | 
| 
      
 59 
     | 
    
         
            +
            complaints will be reviewed and investigated and will result in a response that
         
     | 
| 
      
 60 
     | 
    
         
            +
            is deemed necessary and appropriate to the circumstances. The project team is
         
     | 
| 
      
 61 
     | 
    
         
            +
            obligated to maintain confidentiality with regard to the reporter of an incident.
         
     | 
| 
      
 62 
     | 
    
         
            +
            Further details of specific enforcement policies may be posted separately.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            Project maintainers who do not follow or enforce the Code of Conduct in good
         
     | 
| 
      
 65 
     | 
    
         
            +
            faith may face temporary or permanent repercussions as determined by other
         
     | 
| 
      
 66 
     | 
    
         
            +
            members of the project's leadership.
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            ## Attribution
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
         
     | 
| 
      
 71 
     | 
    
         
            +
            available at [http://contributor-covenant.org/version/1/4][version]
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            [homepage]: http://contributor-covenant.org
         
     | 
| 
      
 74 
     | 
    
         
            +
            [version]: http://contributor-covenant.org/version/1/4/
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                lazada_dino (0.1.0)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  activesupport
         
     | 
| 
      
 6 
     | 
    
         
            +
                  builder (~> 3.2)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  httparty (~> 0.13.7)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  pry
         
     | 
| 
      
 9 
     | 
    
         
            +
                  pry-byebug
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 12 
     | 
    
         
            +
              remote: https://rubygems.org/
         
     | 
| 
      
 13 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 14 
     | 
    
         
            +
                activesupport (5.2.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  i18n (>= 0.7, < 2)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  minitest (~> 5.1)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  tzinfo (~> 1.1)
         
     | 
| 
      
 19 
     | 
    
         
            +
                builder (3.2.3)
         
     | 
| 
      
 20 
     | 
    
         
            +
                byebug (10.0.2)
         
     | 
| 
      
 21 
     | 
    
         
            +
                coderay (1.1.2)
         
     | 
| 
      
 22 
     | 
    
         
            +
                concurrent-ruby (1.0.5)
         
     | 
| 
      
 23 
     | 
    
         
            +
                httparty (0.13.7)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  json (~> 1.8)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  multi_xml (>= 0.5.2)
         
     | 
| 
      
 26 
     | 
    
         
            +
                i18n (1.0.1)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  concurrent-ruby (~> 1.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                json (1.8.6)
         
     | 
| 
      
 29 
     | 
    
         
            +
                method_source (0.9.0)
         
     | 
| 
      
 30 
     | 
    
         
            +
                minitest (5.11.3)
         
     | 
| 
      
 31 
     | 
    
         
            +
                multi_xml (0.6.0)
         
     | 
| 
      
 32 
     | 
    
         
            +
                pry (0.11.3)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  coderay (~> 1.1.0)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  method_source (~> 0.9.0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                pry-byebug (3.6.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  byebug (~> 10.0)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  pry (~> 0.10)
         
     | 
| 
      
 38 
     | 
    
         
            +
                rake (10.5.0)
         
     | 
| 
      
 39 
     | 
    
         
            +
                thread_safe (0.3.6)
         
     | 
| 
      
 40 
     | 
    
         
            +
                tzinfo (1.2.5)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  thread_safe (~> 0.1)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 44 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 47 
     | 
    
         
            +
              bundler (~> 1.11)
         
     | 
| 
      
 48 
     | 
    
         
            +
              lazada_dino!
         
     | 
| 
      
 49 
     | 
    
         
            +
              rake (~> 10.0)
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            BUNDLED WITH
         
     | 
| 
      
 52 
     | 
    
         
            +
               1.16.1
         
     | 
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2018 cySheng
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 13 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
      
 21 
     | 
    
         
            +
            THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,120 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            A Ruby API for http://www.lazada.com.my
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'lazada'
         
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                $ gem install lazada
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ## Lazada::Client
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            The client is the base for all communication with the API.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 26 
     | 
    
         
            +
            client = Lazada::Client.new(api_key, user_id)
         
     | 
| 
      
 27 
     | 
    
         
            +
            ```
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Default timezone is 'UTC'. Can be specified otherwise. Refer to lib/lazada/client.
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ## Lazada::Client methods
         
     | 
| 
      
 32 
     | 
    
         
            +
            ### Lazada::Client#get_products
         
     | 
| 
      
 33 
     | 
    
         
            +
            Get all or a range of products.
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 35 
     | 
    
         
            +
            client.get_products(filter)
         
     | 
| 
      
 36 
     | 
    
         
            +
            ```
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Possible filter values are all, live, inactive, deleted, image-missing, pending, rejected, sold-out.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            ### Lazada::Client#create_product
         
     | 
| 
      
 41 
     | 
    
         
            +
            Create a new product.
         
     | 
| 
      
 42 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 43 
     | 
    
         
            +
            client.create_product({ 'SellerSku' => 'lz001A', ... })
         
     | 
| 
      
 44 
     | 
    
         
            +
            ```
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            ### Lazada::Client#update_product
         
     | 
| 
      
 47 
     | 
    
         
            +
            Update the attributes of one or more existing products.
         
     | 
| 
      
 48 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 49 
     | 
    
         
            +
            client.update_product({ 'SellerSku' => 'lz001A', 'Price' => 12  })
         
     | 
| 
      
 50 
     | 
    
         
            +
            ```
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            ### Lazada::Client#remove_product
         
     | 
| 
      
 53 
     | 
    
         
            +
            Removes one or more products
         
     | 
| 
      
 54 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 55 
     | 
    
         
            +
            client.remove_product(seller_sku)
         
     | 
| 
      
 56 
     | 
    
         
            +
            ```
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            ### Lazada::Client#get_categories
         
     | 
| 
      
 59 
     | 
    
         
            +
            Get the list of all product categories.
         
     | 
| 
      
 60 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 61 
     | 
    
         
            +
            client.get_categories
         
     | 
| 
      
 62 
     | 
    
         
            +
            ```
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ### Lazada::Client#get_category_attributes
         
     | 
| 
      
 65 
     | 
    
         
            +
            Returns a list of attributes with options for a given category.
         
     | 
| 
      
 66 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 67 
     | 
    
         
            +
            cleint.get_category_attributes(primary_category_id)
         
     | 
| 
      
 68 
     | 
    
         
            +
            ```
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            ### Lazada::Client#get_orders
         
     | 
| 
      
 71 
     | 
    
         
            +
            Get the customer details for a range of orders.
         
     | 
| 
      
 72 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 73 
     | 
    
         
            +
            client.get_orders({ status: status })
         
     | 
| 
      
 74 
     | 
    
         
            +
            ```
         
     | 
| 
      
 75 
     | 
    
         
            +
            Possible status values are pending, canceled, ready_to_ship, delivered, returned, shipped and failed.
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            ### Lazada::Client#get_order
         
     | 
| 
      
 78 
     | 
    
         
            +
            Get the order items for a single order.
         
     | 
| 
      
 79 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 80 
     | 
    
         
            +
            client.get_order(order_id)
         
     | 
| 
      
 81 
     | 
    
         
            +
            ```
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            ### Lazada::Client#get_order_items
         
     | 
| 
      
 84 
     | 
    
         
            +
            Returns the items for one order.
         
     | 
| 
      
 85 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 86 
     | 
    
         
            +
            client.get_order_items(order_id)
         
     | 
| 
      
 87 
     | 
    
         
            +
            ```
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            ### Lazada::Client#set_images
         
     | 
| 
      
 90 
     | 
    
         
            +
            Set the Images for a Product, by associating one or more URLs with it.
         
     | 
| 
      
 91 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 92 
     | 
    
         
            +
            client.set_images({ 'ProductImage' => { 'SellerSku' => 'lz001A', 'images' => { ... } } })
         
     | 
| 
      
 93 
     | 
    
         
            +
            ```
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            ### Lazada::Client#feed_status
         
     | 
| 
      
 96 
     | 
    
         
            +
            Returns detailed information about a specified feed.
         
     | 
| 
      
 97 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 98 
     | 
    
         
            +
            client.feed_status(feed_id)
         
     | 
| 
      
 99 
     | 
    
         
            +
            ```
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            ### Lazada::Client#feed_list
         
     | 
| 
      
 102 
     | 
    
         
            +
            Returns all feeds created in the last 30 days.
         
     | 
| 
      
 103 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 104 
     | 
    
         
            +
            client.feed_list
         
     | 
| 
      
 105 
     | 
    
         
            +
            ```
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            ## Development
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            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.
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            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).
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/yoolk/lazada. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "lazada_dino"
         
     | 
| 
      
 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 
     | 
    
         
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         
     | 
| 
      
 10 
     | 
    
         
            +
            # require "pry"
         
     | 
| 
      
 11 
     | 
    
         
            +
            # Pry.start
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            require "irb"
         
     | 
| 
      
 14 
     | 
    
         
            +
            IRB.start(__FILE__)
         
     | 
    
        data/bin/setup
    ADDED
    
    
    
        data/lazada_dino.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "lazada_dino/version"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.name          = "lazada_dino"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.version       = LazadaDino::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
                spec.authors       = ["Sheng Chang"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["cyusheng93@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary       = %q{A ruby wrapper for the Lazada API.}
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.description   = %q{A ruby wrapper for the Lazada API.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage      = "https://github.com/cySheng/lazada"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
         
     | 
| 
      
 18 
     | 
    
         
            +
              # to allow pushing to a single host or delete this section to allow pushing to any host.
         
     | 
| 
      
 19 
     | 
    
         
            +
              # if spec.respond_to?(:metadata)
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
         
     | 
| 
      
 21 
     | 
    
         
            +
              # else
         
     | 
| 
      
 22 
     | 
    
         
            +
              #   raise "RubyGems 2.0 or newer is required to protect against " \
         
     | 
| 
      
 23 
     | 
    
         
            +
              #     "public gem pushes."
         
     | 
| 
      
 24 
     | 
    
         
            +
              # end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
      
 27 
     | 
    
         
            +
              spec.bindir        = "exe"
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_dependency "builder", '~> 3.2'
         
     | 
| 
      
 32 
     | 
    
         
            +
              spec.add_dependency "httparty", "~> 0.13.7"
         
     | 
| 
      
 33 
     | 
    
         
            +
              spec.add_dependency "activesupport"
         
     | 
| 
      
 34 
     | 
    
         
            +
              spec.add_dependency "pry-byebug"
         
     | 
| 
      
 35 
     | 
    
         
            +
              spec.add_dependency "pry"
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 1.11"
         
     | 
| 
      
 38 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/lazada_dino.rb
    ADDED
    
    
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Brand
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def get_brands(options = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    options["Offset"] = 0 unless options["Offset"]
         
     | 
| 
      
 6 
     | 
    
         
            +
                    options["Limit"] = 100 unless options["Limit"]
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    url = request_url('GetBrands', options)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 14 
     | 
    
         
            +
                    response
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Category
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def get_categories
         
     | 
| 
      
 5 
     | 
    
         
            +
                    url = request_url('GetCategoryTree')
         
     | 
| 
      
 6 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 9 
     | 
    
         
            +
                    response
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def get_category_attributes(primary_category_id)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    url = request_url('GetCategoryAttributes', 'PrimaryCategory' => primary_category_id)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 17 
     | 
    
         
            +
                    response
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Feed
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def feed_status(id)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    url = request_url('FeedStatus', { 'FeedID' => id })
         
     | 
| 
      
 6 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    response
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def feed_list
         
     | 
| 
      
 12 
     | 
    
         
            +
                    url = request_url('FeedList')
         
     | 
| 
      
 13 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    response
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Image
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def set_images(params)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    url = request_url('Image')
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                    params = { 'ProductImage' => params }
         
     | 
| 
      
 8 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true))
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    response
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  def migrate_image(image_url)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    url = request_url('MigrateImage')
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    params = { 'Image' => { 'Url' => image_url } }
         
     | 
| 
      
 17 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true))
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    response['SuccessResponse'].present? ? response['SuccessResponse']['Body']['Image']['Url'] : ''
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def migrate_images(image_url_list)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    url = request_url('MigrateImages')
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    # Allow duplicate keys in dict
         
     | 
| 
      
 28 
     | 
    
         
            +
                    urls = {}.compare_by_identity
         
     | 
| 
      
 29 
     | 
    
         
            +
                    image_url_list.each { |image_url| urls.merge!({ String.new('Url') => image_url }) }
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    params = { 'Images' => urls }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true))
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    # At the moment of this writing, the API does not seem to be working in Lazada
         
     | 
| 
      
 38 
     | 
    
         
            +
                    # The response is successful, but does not return a body with the details
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # of the migrated images.
         
     | 
| 
      
 40 
     | 
    
         
            +
                    response['SuccessResponse'].present? ? response['SuccessResponse'] : nil
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Order
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def get_orders(options = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    params = {}
         
     | 
| 
      
 6 
     | 
    
         
            +
                    params['CreatedAfter'] = options[:created_after].iso8601 if options[:created_after].present?
         
     | 
| 
      
 7 
     | 
    
         
            +
                    params['Limit'] = options[:limit] || 100
         
     | 
| 
      
 8 
     | 
    
         
            +
                    params['Offset'] = options[:offset] || 0
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    url = request_url('GetOrders', params)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    return response['SuccessResponse']['Body']['Orders']
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def get_order(id)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    url = request_url('GetOrder', { 'OrderId' => id })
         
     | 
| 
      
 20 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    return response['SuccessResponse']['Body']['Orders']
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def get_order_items(id)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    url = request_url('GetOrderItems', { 'OrderId' => id })
         
     | 
| 
      
 29 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    return response['SuccessResponse']['Body']['OrderItems']
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def get_multiple_order_items(ids_list)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    raise Lazada::LazadaError("IDs list must be an Array of integers or strings") unless ids_list.is_a?(Array)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    url = request_url('GetMultipleOrderItems', { 'OrderIdList' => "[#{ids_list.join(',')}]"})
         
     | 
| 
      
 40 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    return response['SuccessResponse']['Body']['Orders']
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,134 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Product
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def get_products(params = {})
         
     | 
| 
      
 5 
     | 
    
         
            +
                    converted_params = get_product_params(params)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    url = request_url('GetProducts', converted_params)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    response['SuccessResponse']['Body']['Products']
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def create_product(params)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    url = request_url('CreateProduct')
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    params = { 'Product' => product_params(params) }
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true, dasherize: false))
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def update_product(params)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    url = request_url('UpdateProduct')
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    params = { 'Product' => product_params(params) }
         
     | 
| 
      
 28 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true, dasherize: false))
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  def remove_product(seller_sku)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    url = request_url('RemoveProduct')
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    params = {
         
     | 
| 
      
 39 
     | 
    
         
            +
                      'Product' => {
         
     | 
| 
      
 40 
     | 
    
         
            +
                        'Skus' => {
         
     | 
| 
      
 41 
     | 
    
         
            +
                          'Sku' => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                            'SellerSku' => seller_sku
         
     | 
| 
      
 43 
     | 
    
         
            +
                          }
         
     | 
| 
      
 44 
     | 
    
         
            +
                        }
         
     | 
| 
      
 45 
     | 
    
         
            +
                      }
         
     | 
| 
      
 46 
     | 
    
         
            +
                    }
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    response = self.class.post(url, body: params.to_xml(root: 'Request', skip_types: true))
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def get_qc_status
         
     | 
| 
      
 54 
     | 
    
         
            +
                    url = request_url('GetQcStatus')
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    response['SuccessResponse']['Body']['Status']
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  private
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  def get_product_params(object)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    params = {}
         
     | 
| 
      
 67 
     | 
    
         
            +
                    params["CreatedAfter"] = object[:created_after] if object[:created_after].present?
         
     | 
| 
      
 68 
     | 
    
         
            +
                    params["CreatedBefore"] = object[:created_before] if object[:created_before].present?
         
     | 
| 
      
 69 
     | 
    
         
            +
                    params["UpdatedAfter"] = object[:updated_after] if object[:updated_after].present?
         
     | 
| 
      
 70 
     | 
    
         
            +
                    params["UpdatedBefore"] = object[:updated_before] if object[:updated_before].present?
         
     | 
| 
      
 71 
     | 
    
         
            +
                    params["Search"] = object[:search] if object[:search].present?
         
     | 
| 
      
 72 
     | 
    
         
            +
                    object[:filter] = "all" unless object[:filter].present?
         
     | 
| 
      
 73 
     | 
    
         
            +
                    params["Filter"] = object[:filter] if object[:filter].present?
         
     | 
| 
      
 74 
     | 
    
         
            +
                    params["Limit"] = object[:limit] if object[:limit].present?
         
     | 
| 
      
 75 
     | 
    
         
            +
                    params["Options"] = object[:options] if object[:options].present?
         
     | 
| 
      
 76 
     | 
    
         
            +
                    params["Offset"] = object[:offset] if object[:offset].present?
         
     | 
| 
      
 77 
     | 
    
         
            +
                    params["SkuSellerList"] = object[:sku_seller_list] if object[:sku_seller_list].present?
         
     | 
| 
      
 78 
     | 
    
         
            +
                    params
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  def product_params(object)
         
     | 
| 
      
 82 
     | 
    
         
            +
                    params = {}
         
     | 
| 
      
 83 
     | 
    
         
            +
                    params['PrimaryCategory'] = object.delete("primary_category")
         
     | 
| 
      
 84 
     | 
    
         
            +
                    params['SPUId'] = ''
         
     | 
| 
      
 85 
     | 
    
         
            +
                    params['AssociatedSku'] = ''
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                    params['Skus'] = {}
         
     | 
| 
      
 88 
     | 
    
         
            +
                    params['Skus'].compare_by_identity
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    # start variant START
         
     | 
| 
      
 91 
     | 
    
         
            +
                    object["variants"].each do |variant|
         
     | 
| 
      
 92 
     | 
    
         
            +
                      variant_params = {}
         
     | 
| 
      
 93 
     | 
    
         
            +
                      
         
     | 
| 
      
 94 
     | 
    
         
            +
                      variant.delete_if { |k, v| v.empty? || v.nil? }
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                      variant_params['Images'] = {}
         
     | 
| 
      
 97 
     | 
    
         
            +
                      variant_params['Images'].compare_by_identity
         
     | 
| 
      
 98 
     | 
    
         
            +
                      
         
     | 
| 
      
 99 
     | 
    
         
            +
                      if variant['Images'].present? 
         
     | 
| 
      
 100 
     | 
    
         
            +
                        variant['Images'].each do |image|
         
     | 
| 
      
 101 
     | 
    
         
            +
                          url = migrate_image(image)
         
     | 
| 
      
 102 
     | 
    
         
            +
                          variant_params['Images']['Image'.dup] = url
         
     | 
| 
      
 103 
     | 
    
         
            +
                        end
         
     | 
| 
      
 104 
     | 
    
         
            +
                      end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                      variant.delete("Images")
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                      variant.merge!(variant_params)
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                      params['Skus']['Sku'.dup] = variant
         
     | 
| 
      
 111 
     | 
    
         
            +
                    end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                    object.delete("variants")
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                    params['Attributes'] = {}
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                    params['Attributes'] = {
         
     | 
| 
      
 118 
     | 
    
         
            +
                      'name' => object.delete("title") || object.delete("name") ,
         
     | 
| 
      
 119 
     | 
    
         
            +
                      'name_ms' => object.delete("name_ms") || object.delete("name") || object.delete("title"),
         
     | 
| 
      
 120 
     | 
    
         
            +
                      'description' => object.delete("description"),
         
     | 
| 
      
 121 
     | 
    
         
            +
                      'short_description' => object.delete("short_description") || object.delete("highlights"),
         
     | 
| 
      
 122 
     | 
    
         
            +
                      'brand' => object.delete("brand") || 'Unbranded',
         
     | 
| 
      
 123 
     | 
    
         
            +
                      'warranty_type' => object.delete("warranty_type") || 'No Warranty',
         
     | 
| 
      
 124 
     | 
    
         
            +
                      'model' => object.delete("model"),
         
     | 
| 
      
 125 
     | 
    
         
            +
                      'package_content' => object.delete("package_content") || object.delete("box_content")
         
     | 
| 
      
 126 
     | 
    
         
            +
                    }
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                    params['Attributes'].merge!(object)
         
     | 
| 
      
 129 
     | 
    
         
            +
                    params['Attributes'].delete("2_in_1_type") 
         
     | 
| 
      
 130 
     | 
    
         
            +
                    params
         
     | 
| 
      
 131 
     | 
    
         
            +
                  end
         
     | 
| 
      
 132 
     | 
    
         
            +
                end
         
     | 
| 
      
 133 
     | 
    
         
            +
              end
         
     | 
| 
      
 134 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Response
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_reader :response
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(response)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @response = response
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def request_id
         
     | 
| 
      
 11 
     | 
    
         
            +
                    response.dig('SuccessResponse', 'Head', 'RequestId')
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def success?
         
     | 
| 
      
 15 
     | 
    
         
            +
                    response['SuccessResponse'].present?
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def error?
         
     | 
| 
      
 19 
     | 
    
         
            +
                    response['ErrorResponse'].present?
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def warning?
         
     | 
| 
      
 23 
     | 
    
         
            +
                    response.dig('SuccessResponse', 'Body', 'Warnings').present?
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def warning_messages
         
     | 
| 
      
 27 
     | 
    
         
            +
                    hash = {}
         
     | 
| 
      
 28 
     | 
    
         
            +
                    response.dig('SuccessResponse', 'Body', 'Warnings').each do |warning|
         
     | 
| 
      
 29 
     | 
    
         
            +
                      hash[warning['Field'].dup] = warning['Message']
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    hash
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  def error_message
         
     | 
| 
      
 36 
     | 
    
         
            +
                    response.dig('ErrorResponse', 'Head', 'ErrorMessage')
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def error_type
         
     | 
| 
      
 40 
     | 
    
         
            +
                    response.dig('ErrorResponse', 'Head', 'ErrorType')
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  def error_code
         
     | 
| 
      
 44 
     | 
    
         
            +
                    response.dig('ErrorResponse', 'Head', 'ErrorCode')
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  def body_error_messages
         
     | 
| 
      
 48 
     | 
    
         
            +
                    return if response.dig('ErrorResponse').nil?
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    # Parent error coming in the header
         
     | 
| 
      
 51 
     | 
    
         
            +
                    hash = { error: error_message }
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    # Error coming in the body
         
     | 
| 
      
 54 
     | 
    
         
            +
                    response.dig('ErrorResponse', 'Body', 'Errors')&.each do |error|
         
     | 
| 
      
 55 
     | 
    
         
            +
                      hash[error['Field'].dup] = error['Message']
         
     | 
| 
      
 56 
     | 
    
         
            +
                    end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                    hash
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
              module API
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Shipment
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def get_shipment_providers
         
     | 
| 
      
 5 
     | 
    
         
            +
                    url = request_url('GetShipmentProviders')
         
     | 
| 
      
 6 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 11 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def set_status_to_packed(params)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    url = request_url('SetStatusToPackedByMarketplace', params)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 21 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def set_status_to_shipped(params)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    url = request_url('SetStatusToReadyToShip', params)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    response = self.class.get(url)
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    process_response_errors! response
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    return response['SuccessResponse']['Body'] if response['SuccessResponse']
         
     | 
| 
      
 31 
     | 
    
         
            +
                    Lazada::API::Response.new(response)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,91 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'httparty'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'active_support/core_ext/hash'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'pry'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'pry-byebug'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            require 'lazada_dino/api/product'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'lazada_dino/api/category'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'lazada_dino/api/feed'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'lazada_dino/api/image'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'lazada_dino/api/order'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'lazada_dino/api/response'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'lazada_dino/api/brand'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'lazada_dino/api/shipment'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'lazada_dino/exceptions/lazada'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 17 
     | 
    
         
            +
              class Client
         
     | 
| 
      
 18 
     | 
    
         
            +
                include HTTParty
         
     | 
| 
      
 19 
     | 
    
         
            +
                include Lazada::API::Product
         
     | 
| 
      
 20 
     | 
    
         
            +
                include Lazada::API::Category
         
     | 
| 
      
 21 
     | 
    
         
            +
                include Lazada::API::Feed
         
     | 
| 
      
 22 
     | 
    
         
            +
                include Lazada::API::Image
         
     | 
| 
      
 23 
     | 
    
         
            +
                include Lazada::API::Order
         
     | 
| 
      
 24 
     | 
    
         
            +
                include Lazada::API::Brand
         
     | 
| 
      
 25 
     | 
    
         
            +
                include Lazada::API::Shipment
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                base_uri 'https://api.sellercenter.lazada.com.my'
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                # Valid opts:
         
     | 
| 
      
 30 
     | 
    
         
            +
                # - tld: Top level domain to use (.com.my, .sg, .th...). Default: com.my
         
     | 
| 
      
 31 
     | 
    
         
            +
                # - debug: $stdout, Rails.logger. Log http requests
         
     | 
| 
      
 32 
     | 
    
         
            +
                def initialize(api_key, user_id, opts = {})
         
     | 
| 
      
 33 
     | 
    
         
            +
                  @api_key = api_key
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @user_id = user_id
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @timezone = opts[:timezone] || 'Singapore'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @raise_exceptions = opts[:raise_exceptions] || true
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @tld = opts[:tld] || ".com.my"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  # Definitely not thread safe, as the base uri is a class variable.
         
     | 
| 
      
 40 
     | 
    
         
            +
                  # self.class.base_uri "https://api.sellercenter.lazada#{opts[:tld]}" if opts[:tld].present?
         
     | 
| 
      
 41 
     | 
    
         
            +
                  self.class.debug_output opts[:debug] if opts[:debug].present?
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                protected
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def request_url(action, options = {})
         
     | 
| 
      
 47 
     | 
    
         
            +
                  current_time_zone = @timezone
         
     | 
| 
      
 48 
     | 
    
         
            +
                  timestamp = Time.now.in_time_zone(current_time_zone).iso8601
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  # options["filter"] ? filter = options.delete("filter") : filter = ""
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  parameters = {
         
     | 
| 
      
 53 
     | 
    
         
            +
                    'Action' => action,
         
     | 
| 
      
 54 
     | 
    
         
            +
                    'Format' => 'JSON',
         
     | 
| 
      
 55 
     | 
    
         
            +
                    'Timestamp' => timestamp,
         
     | 
| 
      
 56 
     | 
    
         
            +
                    'UserID' => @user_id,
         
     | 
| 
      
 57 
     | 
    
         
            +
                    'Version' => '1.0'
         
     | 
| 
      
 58 
     | 
    
         
            +
                  }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
      
 61 
     | 
    
         
            +
                  parameters = parameters.merge(options) if options.present?
         
     | 
| 
      
 62 
     | 
    
         
            +
                  parameters = Hash[parameters.sort{ |a, b| a[0] <=> b[0] }]
         
     | 
| 
      
 63 
     | 
    
         
            +
                  params     = parameters.to_query
         
     | 
| 
      
 64 
     | 
    
         
            +
                  
         
     | 
| 
      
 65 
     | 
    
         
            +
                  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @api_key, params)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  
         
     | 
| 
      
 67 
     | 
    
         
            +
                  "https://api.sellercenter.lazada#{@tld}/?#{params}&Signature=#{signature}"
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                def process_response_errors!(response)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  return unless @raise_exceptions
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  parsed_response = Lazada::API::Response.new(response)
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  if parsed_response.error?
         
     | 
| 
      
 76 
     | 
    
         
            +
                    raise Lazada::APIError.new(
         
     | 
| 
      
 77 
     | 
    
         
            +
                      "Lazada API Error: '#{parsed_response.error_message}'",
         
     | 
| 
      
 78 
     | 
    
         
            +
                      http_code: response.code,
         
     | 
| 
      
 79 
     | 
    
         
            +
                      response: response.inspect,
         
     | 
| 
      
 80 
     | 
    
         
            +
                      error_type: parsed_response.error_type,
         
     | 
| 
      
 81 
     | 
    
         
            +
                      error_code: parsed_response.error_code,
         
     | 
| 
      
 82 
     | 
    
         
            +
                      error_message: parsed_response.error_message,
         
     | 
| 
      
 83 
     | 
    
         
            +
                      error_detail: parsed_response.body_error_messages,
         
     | 
| 
      
 84 
     | 
    
         
            +
                      request_http_method: response&.request&.http_method&.to_s,
         
     | 
| 
      
 85 
     | 
    
         
            +
                      request_uri: response&.request&.uri&.to_s
         
     | 
| 
      
 86 
     | 
    
         
            +
                    )
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazada
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              class LazadaError < StandardError
         
     | 
| 
      
 4 
     | 
    
         
            +
                def initialize(message = nil)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  super message
         
     | 
| 
      
 6 
     | 
    
         
            +
                end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def detailed_description
         
     | 
| 
      
 9 
     | 
    
         
            +
                  s =  "Message: '#{self.to_s}'"
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  self.instance_variables.each do |iv|
         
     | 
| 
      
 12 
     | 
    
         
            +
                    s += ", #{iv.to_s.gsub(/@/, '')}: '#{self.instance_variable_get(iv)}'"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
                  s
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              class APIError < LazadaError
         
     | 
| 
      
 20 
     | 
    
         
            +
                attr_reader :http_code
         
     | 
| 
      
 21 
     | 
    
         
            +
                attr_reader :response
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                attr_reader :error_type
         
     | 
| 
      
 24 
     | 
    
         
            +
                attr_reader :error_code
         
     | 
| 
      
 25 
     | 
    
         
            +
                attr_reader :error_message
         
     | 
| 
      
 26 
     | 
    
         
            +
                attr_reader :error_detail
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def initialize(message = nil, params = {})
         
     | 
| 
      
 29 
     | 
    
         
            +
                  super message
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  @http_code           = params[:http_code]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @response            = params[:response]
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  @error_type          = params[:error_type]
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @error_code          = params[:error_code]
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @error_message       = params[:error_message]
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @error_detail        = params[:error_detail]
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @request_http_method = params[:request_http_method]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  @request_uri         = params[:request_uri]
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,166 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: lazada_dino
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Sheng Chang
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-05-23 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: builder
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '3.2'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '3.2'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: httparty
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 0.13.7
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 0.13.7
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 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: pry-byebug
         
     | 
| 
      
 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: pry
         
     | 
| 
      
 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.11'
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '1.11'
         
     | 
| 
      
 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 
     | 
    
         
            +
            description: A ruby wrapper for the Lazada API.
         
     | 
| 
      
 112 
     | 
    
         
            +
            email:
         
     | 
| 
      
 113 
     | 
    
         
            +
            - cyusheng93@gmail.com
         
     | 
| 
      
 114 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 115 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 116 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 117 
     | 
    
         
            +
            files:
         
     | 
| 
      
 118 
     | 
    
         
            +
            - ".DS_Store"
         
     | 
| 
      
 119 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 120 
     | 
    
         
            +
            - CODE_OF_CONDUCT.md
         
     | 
| 
      
 121 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 122 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 123 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 124 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 125 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 126 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 127 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
      
 128 
     | 
    
         
            +
            - lazada_dino.gemspec
         
     | 
| 
      
 129 
     | 
    
         
            +
            - lib/lazada_dino.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - lib/lazada_dino/.DS_Store
         
     | 
| 
      
 131 
     | 
    
         
            +
            - lib/lazada_dino/api/brand.rb
         
     | 
| 
      
 132 
     | 
    
         
            +
            - lib/lazada_dino/api/category.rb
         
     | 
| 
      
 133 
     | 
    
         
            +
            - lib/lazada_dino/api/feed.rb
         
     | 
| 
      
 134 
     | 
    
         
            +
            - lib/lazada_dino/api/image.rb
         
     | 
| 
      
 135 
     | 
    
         
            +
            - lib/lazada_dino/api/order.rb
         
     | 
| 
      
 136 
     | 
    
         
            +
            - lib/lazada_dino/api/product.rb
         
     | 
| 
      
 137 
     | 
    
         
            +
            - lib/lazada_dino/api/response.rb
         
     | 
| 
      
 138 
     | 
    
         
            +
            - lib/lazada_dino/api/shipment.rb
         
     | 
| 
      
 139 
     | 
    
         
            +
            - lib/lazada_dino/client.rb
         
     | 
| 
      
 140 
     | 
    
         
            +
            - lib/lazada_dino/exceptions/lazada.rb
         
     | 
| 
      
 141 
     | 
    
         
            +
            - lib/lazada_dino/version.rb
         
     | 
| 
      
 142 
     | 
    
         
            +
            homepage: https://github.com/cySheng/lazada
         
     | 
| 
      
 143 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 144 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 145 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 146 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 147 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 148 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 149 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 150 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 151 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 152 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 153 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 154 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 155 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 156 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 157 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 158 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 159 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 160 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 161 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 162 
     | 
    
         
            +
            rubygems_version: 2.7.3
         
     | 
| 
      
 163 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 164 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 165 
     | 
    
         
            +
            summary: A ruby wrapper for the Lazada API.
         
     | 
| 
      
 166 
     | 
    
         
            +
            test_files: []
         
     |