moysklad 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +14 -3
  5. data/lib/moysklad.rb +3 -2
  6. data/lib/moysklad/client.rb +37 -10
  7. data/lib/moysklad/client/errors.rb +60 -30
  8. data/lib/moysklad/entities.rb +17 -21
  9. data/lib/moysklad/entities/assortment.rb +6 -0
  10. data/lib/moysklad/entities/attachment_document.rb +16 -0
  11. data/lib/moysklad/entities/attribute.rb +114 -37
  12. data/lib/moysklad/entities/attribute_metadata.rb +9 -31
  13. data/lib/moysklad/entities/attribute_value.rb +19 -0
  14. data/lib/moysklad/entities/barcode.rb +10 -4
  15. data/lib/moysklad/entities/base.rb +23 -8
  16. data/lib/moysklad/entities/bundle.rb +39 -0
  17. data/lib/moysklad/entities/characteristic.rb +6 -0
  18. data/lib/moysklad/entities/characteristic_metadata.rb +6 -0
  19. data/lib/moysklad/entities/collection.rb +30 -7
  20. data/lib/moysklad/entities/collection_meta.rb +11 -0
  21. data/lib/moysklad/entities/common_object.rb +0 -2
  22. data/lib/moysklad/entities/company_settings_metadata.rb +28 -0
  23. data/lib/moysklad/entities/consignment.rb +19 -17
  24. data/lib/moysklad/entities/context.rb +9 -0
  25. data/lib/moysklad/entities/counterparty.rb +18 -0
  26. data/lib/moysklad/entities/currency.rb +29 -0
  27. data/lib/moysklad/entities/custom_entity.rb +20 -10
  28. data/lib/moysklad/entities/custom_entity_metadata.rb +7 -32
  29. data/lib/moysklad/entities/customer_order.rb +116 -23
  30. data/lib/moysklad/entities/customer_order_position.rb +10 -18
  31. data/lib/moysklad/entities/employee.rb +7 -0
  32. data/lib/moysklad/entities/entity.rb +42 -0
  33. data/lib/moysklad/entities/good_folder.rb +1 -0
  34. data/lib/moysklad/entities/group.rb +7 -0
  35. data/lib/moysklad/entities/image.rb +17 -0
  36. data/lib/moysklad/entities/images.rb +10 -0
  37. data/lib/moysklad/entities/meta.rb +14 -0
  38. data/lib/moysklad/entities/organization.rb +19 -0
  39. data/lib/moysklad/entities/owner.rb +4 -0
  40. data/lib/moysklad/entities/price.rb +5 -8
  41. data/lib/moysklad/entities/price_type.rb +2 -8
  42. data/lib/moysklad/entities/product.rb +54 -0
  43. data/lib/moysklad/entities/productfolder.rb +13 -0
  44. data/lib/moysklad/entities/rate.rb +9 -0
  45. data/lib/moysklad/entities/resource_metadata.rb +13 -0
  46. data/lib/moysklad/entities/service.rb +28 -0
  47. data/lib/moysklad/entities/shortcut.rb +11 -0
  48. data/lib/moysklad/entities/store.rb +10 -0
  49. data/lib/moysklad/entities/time.rb +13 -0
  50. data/lib/moysklad/entities/uom.rb +7 -0
  51. data/lib/moysklad/entities/variant.rb +51 -0
  52. data/lib/moysklad/entities/workflow.rb +11 -0
  53. data/lib/moysklad/entities/workflow_state.rb +8 -0
  54. data/lib/moysklad/error.rb +1 -0
  55. data/lib/moysklad/resources.rb +9 -7
  56. data/lib/moysklad/resources/assortments.rb +14 -0
  57. data/lib/moysklad/resources/base.rb +32 -44
  58. data/lib/moysklad/resources/custom_entities.rb +27 -0
  59. data/lib/moysklad/resources/custom_entity_metadata.rb +12 -8
  60. data/lib/moysklad/resources/embedded_entity_metadata.rb +0 -1
  61. data/lib/moysklad/resources/indexed.rb +23 -35
  62. data/lib/moysklad/resources/indexed_cache.rb +36 -0
  63. data/lib/moysklad/resources/load_all.rb +21 -0
  64. data/lib/moysklad/resources/products.rb +10 -0
  65. data/lib/moysklad/resources/where_filter.rb +0 -1
  66. data/lib/moysklad/universe.rb +16 -2
  67. data/lib/moysklad/version.rb +1 -1
  68. data/moysklad.gemspec +3 -1
  69. data/scripts/rest.sh +5 -2
  70. data/spec/fixtures/Good_WithManyAttributes.raw +13 -0
  71. data/spec/fixtures/Workflow_list.raw +15 -0
  72. data/spec/fixtures/good_with_image.xml +39 -0
  73. data/spec/lib/moysklad/entities/customer_order_spec.rb +7 -2
  74. data/spec/lib/moysklad/entities/good_spec.rb +9 -0
  75. data/spec/lib/moysklad/resources/workflows_spec.rb +21 -0
  76. data/spec/spec_helper.rb +2 -1
  77. data/test.rb +177 -0
  78. metadata +97 -44
  79. data/lib/moysklad/entities/common.rb +0 -15
  80. data/lib/moysklad/entities/feature.rb +0 -20
  81. data/lib/moysklad/entities/good.rb +0 -34
  82. data/lib/moysklad/entities/stock_to.rb +0 -33
  83. data/lib/moysklad/entities/warehouse.rb +0 -15
  84. data/lib/moysklad/entities/xml_fix.rb +0 -15
@@ -1,20 +0,0 @@
1
- module Moysklad::Entities
2
- class Feature < Base
3
- include CommonObject
4
-
5
- tag 'feature'
6
-
7
- attribute :goodUuid, String
8
-
9
- attribute :archived, Boolean
10
-
11
- has_many :attributes, Moysklad::Entities::Attribute
12
- has_many :barcodes, Moysklad::Entities::Barcode
13
-
14
- def good universe
15
- cache :good, universe do
16
- universe.good.find goodUuid
17
- end
18
- end
19
- end
20
- end
@@ -1,34 +0,0 @@
1
- module Moysklad::Entities
2
- class Good < Base
3
- include CommonObject
4
- include Moysklad::Entities::XmlFix
5
-
6
- tag 'good'
7
-
8
- attribute :isSerialTrackable, Boolean
9
- attribute :buyPrice, Float
10
- attribute :buyCurrencyUuid, String
11
- attribute :minPrice, Float
12
- attribute :salePrice, Float
13
- attribute :saleCurrencyUuid, String
14
- attribute :weight, Float
15
- attribute :volume, Float
16
- attribute :parentUuid, String
17
- attribute :productCode, String
18
- attribute :uomUuid, String
19
-
20
- element :code, String
21
- element :salePrices, Moysklad::Entities::SalePrices
22
-
23
- has_many :attributes, Attribute
24
-
25
- # preferences
26
- # images
27
-
28
- def features universe
29
- cache :features, universe do
30
- universe.features.where goodUuid: uuid
31
- end
32
- end
33
- end
34
- end
@@ -1,33 +0,0 @@
1
- module Moysklad::Entities
2
- class StockTO < Base
3
- include HappyMapper
4
- include Moysklad::Entities::XmlFix
5
-
6
- tag 'stockTO'
7
-
8
- attribute :productCode, String
9
- attribute :uomName, String
10
-
11
- attribute :quantity, Float # Доступный остаток на склада
12
- attribute :reserve, Float # Сколько в резерве
13
- attribute :stock, Float # Остаток на складе не считая резерва
14
-
15
- attribute :inTransit, Float
16
- attribute :sumTotal, Float
17
- attribute :saleAmount, Float
18
- attribute :minimumBalance, Float
19
- attribute :category, String
20
- attribute :externalCode, String
21
- attribute :parentUuid, String
22
- attribute :defaultConsignment, Boolean
23
- attribute :salePrice, Float
24
-
25
- # Есть только при showConsignments
26
- attribute :consignmentName, String
27
- attribute :consignmentUuid, String
28
-
29
- element :goodRef, Moysklad::Entities::GoodRef
30
-
31
- end
32
- end
33
-
@@ -1,15 +0,0 @@
1
- module Moysklad::Entities
2
- # https://online.moysklad.ru/exchange/rest/ms/xml/Warehouse/list
3
- class Warehouse < Base
4
- include CommonObject
5
-
6
- tag 'warehouse'
7
-
8
- attribute :agentUuid, String
9
- attribute :archived, Boolean
10
- attribute :code, String
11
-
12
- element :contact, Contact
13
- has_many :slots, Slot
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Moysklad::Entities::XmlFix
2
- extend ::ActiveSupport::Concern
3
-
4
- def to_xml builder = nil,default_namespace = nil,tag_from_parent = nil
5
- unless builder
6
- builder = Nokogiri::XML::Builder.new(encoding: 'utf-8')
7
- write_out_to_xml = true
8
- end
9
-
10
- result = super builder, default_namespace, tag_from_parent
11
-
12
- write_out_to_xml ? result.to_xml : result
13
- end
14
-
15
- end