plenty_client 0.0.1

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +43 -0
  5. data/.travis.yml +5 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +154 -0
  10. data/Rakefile +6 -0
  11. data/lib/plenty_client/config.rb +15 -0
  12. data/lib/plenty_client/constants.rb +362 -0
  13. data/lib/plenty_client/endpoint.rb +73 -0
  14. data/lib/plenty_client/item/attribute/name.rb +52 -0
  15. data/lib/plenty_client/item/attribute/value.rb +52 -0
  16. data/lib/plenty_client/item/attribute/value_name.rb +52 -0
  17. data/lib/plenty_client/item/attribute.rb +36 -0
  18. data/lib/plenty_client/item/barcode.rb +56 -0
  19. data/lib/plenty_client/item/cross_selling.rb +26 -0
  20. data/lib/plenty_client/item/image/availability.rb +37 -0
  21. data/lib/plenty_client/item/image/name.rb +57 -0
  22. data/lib/plenty_client/item/image.rb +53 -0
  23. data/lib/plenty_client/item/manufacturer/commission.rb +52 -0
  24. data/lib/plenty_client/item/manufacturer.rb +36 -0
  25. data/lib/plenty_client/item/property/market_reference.rb +52 -0
  26. data/lib/plenty_client/item/property/name.rb +52 -0
  27. data/lib/plenty_client/item/property.rb +36 -0
  28. data/lib/plenty_client/item/property_group.rb +36 -0
  29. data/lib/plenty_client/item/property_group_name.rb +44 -0
  30. data/lib/plenty_client/item/sales_price.rb +37 -0
  31. data/lib/plenty_client/item/shipping_profile.rb +26 -0
  32. data/lib/plenty_client/item/unit.rb +35 -0
  33. data/lib/plenty_client/item/unit_name.rb +38 -0
  34. data/lib/plenty_client/item/variation/barcode.rb +53 -0
  35. data/lib/plenty_client/item/variation/bundle.rb +52 -0
  36. data/lib/plenty_client/item/variation/category.rb +52 -0
  37. data/lib/plenty_client/item/variation/client.rb +37 -0
  38. data/lib/plenty_client/item/variation/default_category.rb +45 -0
  39. data/lib/plenty_client/item/variation/description.rb +53 -0
  40. data/lib/plenty_client/item/variation/image.rb +49 -0
  41. data/lib/plenty_client/item/variation/market.rb +37 -0
  42. data/lib/plenty_client/item/variation/market_ident_number.rb +53 -0
  43. data/lib/plenty_client/item/variation/sales_price.rb +53 -0
  44. data/lib/plenty_client/item/variation/sku.rb +52 -0
  45. data/lib/plenty_client/item/variation/stock.rb +57 -0
  46. data/lib/plenty_client/item/variation/supplier.rb +52 -0
  47. data/lib/plenty_client/item/variation/warehouse.rb +52 -0
  48. data/lib/plenty_client/item/variation.rb +35 -0
  49. data/lib/plenty_client/item/variation_property.rb +36 -0
  50. data/lib/plenty_client/item/variation_property_value.rb +48 -0
  51. data/lib/plenty_client/item.rb +24 -0
  52. data/lib/plenty_client/item_set/component.rb +54 -0
  53. data/lib/plenty_client/item_set/config.rb +20 -0
  54. data/lib/plenty_client/item_set.rb +44 -0
  55. data/lib/plenty_client/order/contact_wish.rb +17 -0
  56. data/lib/plenty_client/order/coupon_code/contact.rb +20 -0
  57. data/lib/plenty_client/order/coupon_code/validation.rb +20 -0
  58. data/lib/plenty_client/order/coupon_code.rb +19 -0
  59. data/lib/plenty_client/order/currency.rb +32 -0
  60. data/lib/plenty_client/order/date.rb +32 -0
  61. data/lib/plenty_client/order/item/date.rb +20 -0
  62. data/lib/plenty_client/order/item/property.rb +20 -0
  63. data/lib/plenty_client/order/item/serial_number.rb +25 -0
  64. data/lib/plenty_client/order/item.rb +18 -0
  65. data/lib/plenty_client/order/property.rb +21 -0
  66. data/lib/plenty_client/order/referrer.rb +22 -0
  67. data/lib/plenty_client/order/shipping/country.rb +18 -0
  68. data/lib/plenty_client/order/shipping/information.rb +45 -0
  69. data/lib/plenty_client/order/shipping/package.rb +54 -0
  70. data/lib/plenty_client/order/shipping/profile.rb +23 -0
  71. data/lib/plenty_client/order/shipping/service_provider.rb +27 -0
  72. data/lib/plenty_client/order/shipping.rb +12 -0
  73. data/lib/plenty_client/order.rb +43 -0
  74. data/lib/plenty_client/request.rb +128 -0
  75. data/lib/plenty_client/sales_price/account.rb +30 -0
  76. data/lib/plenty_client/sales_price/country.rb +26 -0
  77. data/lib/plenty_client/sales_price/currency.rb +26 -0
  78. data/lib/plenty_client/sales_price/customer_class.rb +31 -0
  79. data/lib/plenty_client/sales_price/name.rb +36 -0
  80. data/lib/plenty_client/sales_price/online_store.rb +29 -0
  81. data/lib/plenty_client/sales_price/referrer.rb +25 -0
  82. data/lib/plenty_client/version.rb +3 -0
  83. data/lib/plenty_client.rb +108 -0
  84. data/plenty_client.gemspec +29 -0
  85. metadata +204 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: df01cb8f8df7f62a1a367ae679ef7326c7d861d6
4
+ data.tar.gz: 1fb7060354dec458e6ebb1a70e9e7d3345fee8ce
5
+ SHA512:
6
+ metadata.gz: 52ff8c31d2ba058e438c06aad948c56516abd8a50fb153b78ad34749636ebe8aa56684c321364b83e2ac1503be84a2c41334a449a95c1e267c86ba5d93fb0316
7
+ data.tar.gz: 261c38a16937ad2e2a7f3100c132a155d1d7ed7509386f4921ac12dee9769dbb15cc54ad02dd0d2ddc88a836f49a19c8d6f8cd495b0a810f64acbc10d3e1819a
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ Gemfile.lock
2
+
3
+ *.gem
4
+
5
+ .DS_Store
6
+ .bundle
7
+ .rvmrc
8
+ .rbenv-version
9
+ .config
10
+ .yardoc
11
+ InstalledFiles
12
+ _yardoc
13
+ coverage
14
+ doc/
15
+ bin/
16
+ lib/bundler/man
17
+ pkg
18
+ rdoc
19
+ spec/reports
20
+ test/tmp
21
+ test/version_tmp
22
+ tmp
23
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,43 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+ AllCops:
3
+ TargetRubyVersion: 2.3
4
+ Exclude:
5
+ - 'db/schema.rb'
6
+ Lint/HandleExceptions:
7
+ Exclude:
8
+ - 'bin/console'
9
+ - 'bin/eun'
10
+ - 'bin/setup'
11
+
12
+ Style/FrozenStringLiteralComment:
13
+ Enabled: false
14
+ Style/Encoding:
15
+ Enabled: true
16
+ Style/NumericLiterals:
17
+ Enabled: false
18
+ Style/RescueModifier:
19
+ Enabled: false
20
+ Style/Documentation:
21
+ Enabled: false
22
+ Style/GuardClause:
23
+ Description: Check for conditionals that can be replaced with guard clauses
24
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
25
+ Enabled: true
26
+ MinBodyLength: 1
27
+
28
+ Metrics/LineLength:
29
+ Max: 120
30
+ Metrics/AbcSize:
31
+ Max: 999
32
+ Metrics/ClassLength:
33
+ Max: 999
34
+ Metrics/CyclomaticComplexity:
35
+ Max: 99
36
+ Metrics/MethodLength:
37
+ Max: 999
38
+ Metrics/ModuleLength:
39
+ Max: 999
40
+ Metrics/ParameterLists:
41
+ Max: 10
42
+ Metrics/PerceivedComplexity:
43
+ Max: 99
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
@@ -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 dariusch.ochlast@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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in plenty_client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Dariusch Ochlast
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,154 @@
1
+ # PlentyClient
2
+ [![Code Climate](https://codeclimate.com/github/Dariusch/plenty_client/badges/gpa.svg)](https://codeclimate.com/github/Dariusch/plenty_client)
3
+ [![Issue Count](https://codeclimate.com/github/Dariusch/plenty_client/badges/issue_count.svg)](https://codeclimate.com/github/Dariusch/plenty_client)
4
+ [![Test Coverage](https://codeclimate.com/github/Dariusch/plenty_client/badges/coverage.svg)](https://codeclimate.com/github/Dariusch/plenty_client/coverage)
5
+ [![Build Status](https://travis-ci.org/Dariusch/plenty_client.svg?branch=master)](https://travis-ci.org/Dariusch/plenty_client)
6
+
7
+ This Client is a ruby wrapper around the PlentyMarkets REST API.
8
+ The complete documentation can be found [here](https://developers.plentymarkets.com/rest-doc).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+ ```
14
+ gem 'plenty_client'
15
+ ```
16
+
17
+ And then execute:
18
+ ```ruby
19
+ bundle install
20
+ ```
21
+
22
+ Or install it yourself as:
23
+ ```ruby
24
+ gem install plenty_client
25
+ ```
26
+
27
+ ## Getting Started
28
+
29
+ ### Configuration
30
+ PlentyClient is a simple Ruby library. It works with Rails, as well as in a simple irb.
31
+ Make sure you configure the PlentyClient with the following options:
32
+
33
+ ```ruby
34
+ PlentyClient::Config.site_url = 'http://plenty7.plentymarkets.de/rest'
35
+ PlentyClient::Config.api_user = 'myusername'
36
+ PlentyClient::Config.api_password = 'mypassword'
37
+ PlentyClient::Config.log = true || false
38
+ ```
39
+
40
+ # Calls
41
+ Once you are set up you can use the client with the following methods:
42
+
43
+ Note:
44
+ - required parameters need to be passed in, otherwise you will get an error
45
+ - This Client handles no validation, it is only a gateway to the API
46
+
47
+ ```ruby
48
+ PlentyClient::Item.find(103)
49
+ PlentyClient::Item::Variation.find(103, 105)
50
+
51
+ PlentyClient::Item.list
52
+ PlentyClient::Item::Variation.list
53
+
54
+ PlentyClient::Item.create(parameters)
55
+
56
+ PlentyClient::Item::Variation.update(103, update_parameters)
57
+
58
+ PlentyClient::Item::Variation.delete(103, 105)
59
+
60
+ ```
61
+
62
+ ### Blocks
63
+
64
+ ```ruby
65
+ # Use blocks to iterate in batches
66
+ PlentyClient::Item.list do |item|
67
+ puts item
68
+ end
69
+
70
+ # You can set optional headers after the required parameters of each request
71
+ PlentyClient::Item::Variation.list(103, {'itemsPerPage' => 1, 'page' => 4}) do |item|
72
+ puts item
73
+ end
74
+ ```
75
+
76
+ ### HTTP-Methods
77
+
78
+ If there is no resource available you can still make the request like so:
79
+ ```ruby
80
+ PlentyClient::Request.patch(path, body = {})
81
+ PlentyClient::Request.put(path, body = {})
82
+ PlentyClient::Request.post(path, body = {})
83
+ PlentyClient::Request.delete(path, params = {})
84
+ PlentyClient::Request.get(path, params = {})
85
+ PlentyClient::Request.get(path, params = {}) do |body|
86
+ end
87
+ ```
88
+
89
+ ### Warnings
90
+ There is a difference in the get method with and without a block.
91
+ This returns the raw body with all parameters
92
+
93
+ ```ruby
94
+ PlentyClient::Request.get(path, params = {})
95
+
96
+ ```
97
+ The get-call with the block only returns the entries
98
+ ```ruby
99
+ PlentyClient::Request.get(path, params = {}) do |body|
100
+ puts entries
101
+ end
102
+
103
+ ```
104
+
105
+ ### Debugging
106
+ If you are not sure which required parameters to pass in simply call
107
+
108
+ ```ruby
109
+ PlentyClient::Item::Variation.routes
110
+ ```
111
+
112
+ ## Todo:
113
+
114
+ - write some specs
115
+ - clean up `plenty_client/request.rb`
116
+ * create classes for
117
+ * [`Account`](https://developers.plentymarkets.com/rest-doc/account)
118
+ * [`Accounting`](https://developers.plentymarkets.com/rest-doc/accounting)
119
+ * [`Authentication`](https://developers.plentymarkets.com/rest-doc/authentication)
120
+ * [`Authorization`](https://developers.plentymarkets.com/rest-doc/authorization)
121
+ * [`Basket`](https://developers.plentymarkets.com/rest-doc/basket)
122
+ * [`Category`](https://developers.plentymarkets.com/rest-doc/category)
123
+ * [`Cloud`](https://developers.plentymarkets.com/rest-doc/cloud)
124
+ * [`Comment`](https://developers.plentymarkets.com/rest-doc/comment)
125
+ * [`Document`](https://developers.plentymarkets.com/rest-doc/document)
126
+ * [`Export`](https://developers.plentymarkets.com/rest-doc/export)
127
+ * [`ExportSettings`](https://developers.plentymarkets.com/rest-doc/export_settings)
128
+ * [~~`Item`~~](https://developers.plentymarkets.com/rest-doc/item)
129
+ * [`LegalInformation`](https://developers.plentymarkets.com/rest-doc/legal_information)
130
+ * [`Market`](https://developers.plentymarkets.com/rest-doc/market)
131
+ * [~~`Order`~~](https://developers.plentymarkets.com/rest-doc/order)
132
+ * [`OrderSummary`](https://developers.plentymarkets.com/rest-doc/order_summary)
133
+ * [`Payment`](https://developers.plentymarkets.com/rest-doc/payment)
134
+ * [`Plugins`](https://developers.plentymarkets.com/rest-doc/plugins)
135
+ * [`StockManagement`](https://developers.plentymarkets.com/rest-doc/stock_management)
136
+ * [`Ticket`](https://developers.plentymarkets.com/rest-doc/ticket)
137
+ * [`Webstore`](https://developers.plentymarkets.com/rest-doc/webstore)
138
+ - missing [OrderItem OrderItemDate](https://developers.plentymarkets.com/rest-doc/order_order_item_order_item_date/details#get-all-order-item-dates-for-one-order-item-by-its-order-item-id) - its just a mess
139
+ - missing [OrderProperty](https://developers.plentymarkets.com/rest-doc/order#rest-orderproperty) - its just a mess
140
+ - missing [OrderItem OrderItemProperty ](https://developers.plentymarkets.com/rest-doc/order_order_item_order_item_property/details#get-all-order-item-propertys-for-one-order-item-by-its-order-item-id) - its just a mess
141
+ - update all modules to classes and make it inherit from a base class to remove `extend PlentyClient::Request` etc
142
+ - create a configure block to set authentication parameters
143
+
144
+ ## Contributing
145
+
146
+ Bug reports and pull requests are welcome.
147
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
148
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
149
+
150
+
151
+ ## License
152
+
153
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
154
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ module PlentyClient
2
+ class Config
3
+ class NoCredentials < StandardError; end
4
+ class NoToken < StandardError; end
5
+
6
+ class << self
7
+ attr_accessor :site_url, :api_user, :api_password, :access_token, :refresh_token, :log
8
+
9
+ def validate
10
+ raise NoCredentials if site_url.nil? || api_user.nil? || api_password.nil?
11
+ raise NoToken if access_token.nil? || refresh_token.nil?
12
+ end
13
+ end
14
+ end
15
+ end