amo_crm 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +29 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +1 -0
  10. data/Rakefile +14 -0
  11. data/amo_crm.gemspec +41 -0
  12. data/dump_amocrm_account.rb +7 -0
  13. data/lib/amo_crm.rb +31 -0
  14. data/lib/amo_crm/client.rb +98 -0
  15. data/lib/amo_crm/client/error.rb +18 -0
  16. data/lib/amo_crm/client/errors.rb +16 -0
  17. data/lib/amo_crm/entities.rb +14 -0
  18. data/lib/amo_crm/entities/account.rb +7 -0
  19. data/lib/amo_crm/entities/attachment_document.rb +16 -0
  20. data/lib/amo_crm/entities/attribute.rb +71 -0
  21. data/lib/amo_crm/entities/attribute_metadata.rb +38 -0
  22. data/lib/amo_crm/entities/barcode.rb +19 -0
  23. data/lib/amo_crm/entities/base.rb +5 -0
  24. data/lib/amo_crm/entities/collection.rb +12 -0
  25. data/lib/amo_crm/entities/common.rb +15 -0
  26. data/lib/amo_crm/entities/common_object.rb +27 -0
  27. data/lib/amo_crm/entities/company.rb +30 -0
  28. data/lib/amo_crm/entities/company_concern.rb +20 -0
  29. data/lib/amo_crm/entities/consignment.rb +22 -0
  30. data/lib/amo_crm/entities/contact.rb +29 -0
  31. data/lib/amo_crm/entities/contract.rb +2 -0
  32. data/lib/amo_crm/entities/country.rb +10 -0
  33. data/lib/amo_crm/entities/custom_entity.rb +18 -0
  34. data/lib/amo_crm/entities/custom_entity_metadata.rb +36 -0
  35. data/lib/amo_crm/entities/custom_field.rb +6 -0
  36. data/lib/amo_crm/entities/custom_field_definition.rb +13 -0
  37. data/lib/amo_crm/entities/custom_field_value.rb +5 -0
  38. data/lib/amo_crm/entities/custom_fields.rb +24 -0
  39. data/lib/amo_crm/entities/custom_fields_definition.rb +4 -0
  40. data/lib/amo_crm/entities/customer_order.rb +51 -0
  41. data/lib/amo_crm/entities/customer_order_position.rb +22 -0
  42. data/lib/amo_crm/entities/embedded_entity_metadata.rb +18 -0
  43. data/lib/amo_crm/entities/error.rb +13 -0
  44. data/lib/amo_crm/entities/feature.rb +23 -0
  45. data/lib/amo_crm/entities/good.rb +34 -0
  46. data/lib/amo_crm/entities/good_folder.rb +10 -0
  47. data/lib/amo_crm/entities/good_ref.rb +12 -0
  48. data/lib/amo_crm/entities/image.rb +21 -0
  49. data/lib/amo_crm/entities/images.rb +10 -0
  50. data/lib/amo_crm/entities/lead.rb +28 -0
  51. data/lib/amo_crm/entities/my_company.rb +12 -0
  52. data/lib/amo_crm/entities/page.rb +5 -0
  53. data/lib/amo_crm/entities/price.rb +15 -0
  54. data/lib/amo_crm/entities/price_type.rb +13 -0
  55. data/lib/amo_crm/entities/sale_price.rb +18 -0
  56. data/lib/amo_crm/entities/sale_prices.rb +10 -0
  57. data/lib/amo_crm/entities/slot.rb +10 -0
  58. data/lib/amo_crm/entities/stock_to.rb +33 -0
  59. data/lib/amo_crm/entities/warehouse.rb +15 -0
  60. data/lib/amo_crm/entities/workflow.rb +11 -0
  61. data/lib/amo_crm/entities/workflow_state.rb +8 -0
  62. data/lib/amo_crm/entities/xml_fix.rb +14 -0
  63. data/lib/amo_crm/errors.rb +1 -0
  64. data/lib/amo_crm/resources.rb +18 -0
  65. data/lib/amo_crm/resources/account.rb +30 -0
  66. data/lib/amo_crm/resources/base.rb +149 -0
  67. data/lib/amo_crm/resources/companies.rb +27 -0
  68. data/lib/amo_crm/resources/contacts.rb +23 -0
  69. data/lib/amo_crm/resources/custom_entity_metadata.rb +18 -0
  70. data/lib/amo_crm/resources/custom_field.rb +28 -0
  71. data/lib/amo_crm/resources/embedded_entity_metadata.rb +20 -0
  72. data/lib/amo_crm/resources/embedded_entity_metadata_indexed.rb +7 -0
  73. data/lib/amo_crm/resources/indexed.rb +89 -0
  74. data/lib/amo_crm/resources/leads.rb +31 -0
  75. data/lib/amo_crm/resources/stock.rb +36 -0
  76. data/lib/amo_crm/resources/subresource.rb +21 -0
  77. data/lib/amo_crm/resources/where_filter.rb +26 -0
  78. data/lib/amo_crm/response.rb +7 -0
  79. data/lib/amo_crm/universe.rb +44 -0
  80. data/lib/amo_crm/version.rb +3 -0
  81. data/scripts/rest.sh +25 -0
  82. data/spec/fixtures/302.raw +15 -0
  83. data/spec/fixtures/400.raw +8 -0
  84. data/spec/fixtures/401.html +1 -0
  85. data/spec/fixtures/401_2.html +1 -0
  86. data/spec/fixtures/405.raw +9 -0
  87. data/spec/fixtures/500.raw +8 -0
  88. data/spec/fixtures/502.raw +8 -0
  89. data/spec/fixtures/Consignment_list_0.raw +14 -0
  90. data/spec/fixtures/Consignment_list_1000.raw +14 -0
  91. data/spec/fixtures/Country_list.raw +14 -0
  92. data/spec/fixtures/CustomEntityMetadata_list.raw +14 -0
  93. data/spec/fixtures/CustomEntity_list.raw +14 -0
  94. data/spec/fixtures/CustomEntity_list_bad_chars.raw +17 -0
  95. data/spec/fixtures/EmbeddedEntityMetadata_list.raw +15 -0
  96. data/spec/fixtures/Feature_list.raw +14 -0
  97. data/spec/fixtures/Feature_list_1000.raw +14 -0
  98. data/spec/fixtures/Good_WithManyAttributes.raw +13 -0
  99. data/spec/fixtures/Good_e932ebe1-2e22-11e4-9406-002590a28eca.raw +12 -0
  100. data/spec/fixtures/Good_eb77ad57-2e22-11e4-4030-002590a28eca.raw +12 -0
  101. data/spec/fixtures/Goods_list.raw +14 -0
  102. data/spec/fixtures/Metadata_list.raw +14 -0
  103. data/spec/fixtures/PriceType_list.raw +14 -0
  104. data/spec/fixtures/Stock.raw +11 -0
  105. data/spec/fixtures/Stock_showConsignments.raw +11 -0
  106. data/spec/fixtures/Uom_list.raw +14 -0
  107. data/spec/fixtures/Warehouse_list.raw +14 -0
  108. data/spec/fixtures/Workflow_list.raw +15 -0
  109. data/spec/fixtures/attribute_boolean.xml +6 -0
  110. data/spec/fixtures/attribute_dictionary.xml +5 -0
  111. data/spec/fixtures/attribute_double.xml +6 -0
  112. data/spec/fixtures/attribute_file.xml +12 -0
  113. data/spec/fixtures/attribute_long.xml +6 -0
  114. data/spec/fixtures/attribute_text.xml +5 -0
  115. data/spec/fixtures/attribute_time.xml +6 -0
  116. data/spec/fixtures/attribute_url.xml +6 -0
  117. data/spec/fixtures/bad_chars.xml +6 -0
  118. data/spec/fixtures/customer_order.xml +28 -0
  119. data/spec/fixtures/good_with_attributes.raw +12 -0
  120. data/spec/fixtures/good_with_image.xml +39 -0
  121. data/spec/fixtures/resource_forbidden.raw +9 -0
  122. data/spec/fixtures/wrong_password.raw +9 -0
  123. data/spec/fixtures/wrong_type.raw +70 -0
  124. data/spec/fixtures/wrong_user.raw +9 -0
  125. data/spec/lib/amocrm/client/errors_spec.rb +102 -0
  126. data/spec/lib/amocrm/entities/attribute_metadata_spec.rb +30 -0
  127. data/spec/lib/amocrm/entities/attribute_spec.rb +36 -0
  128. data/spec/lib/amocrm/entities/country_spec.rb +25 -0
  129. data/spec/lib/amocrm/entities/custom_entity_metadata_spec.rb +34 -0
  130. data/spec/lib/amocrm/entities/custom_entity_spec.rb +34 -0
  131. data/spec/lib/amocrm/entities/customer_order_position_spec.rb +35 -0
  132. data/spec/lib/amocrm/entities/customer_order_spec.rb +58 -0
  133. data/spec/lib/amocrm/entities/good_spec.rb +55 -0
  134. data/spec/lib/amocrm/resources/base_spec.rb +61 -0
  135. data/spec/lib/amocrm/resources/countries_spec.rb +22 -0
  136. data/spec/lib/amocrm/resources/custom_entity_metadata_spec.rb +13 -0
  137. data/spec/lib/amocrm/resources/embedded_entity_metadata_indexed_spec.rb +20 -0
  138. data/spec/lib/amocrm/resources/embedded_entity_metadata_spec.rb +11 -0
  139. data/spec/lib/amocrm/resources/good_folders_spec.rb +17 -0
  140. data/spec/lib/amocrm/resources/indexed_spec.rb +61 -0
  141. data/spec/lib/amocrm/resources/stock_spec.rb +63 -0
  142. data/spec/lib/amocrm/resources/subresource_spec.rb +13 -0
  143. data/spec/lib/amocrm/resources/warehouses_spec.rb +20 -0
  144. data/spec/lib/amocrm/resources/workflows_spec.rb +21 -0
  145. data/spec/lib/amocrm/resources_spec.rb +10 -0
  146. data/spec/lib/amocrm/universe_spec.rb +53 -0
  147. data/spec/lib/amocrm_spec.rb +8 -0
  148. data/spec/spec_helper.rb +106 -0
  149. data/spec/support/resource.rb +72 -0
  150. metadata +500 -0
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.6.2
3
+ Date: Tue, 25 Nov 2014 12:01:30 GMT
4
+ Content-Type: application/xml
5
+ Content-Length: 2605
6
+ Connection: close
7
+ Cache-Control: max-age=0
8
+ Expires: Tue, 25 Nov 2014 12:01:30 GMT
9
+ Strict-Transport-Security: max-age=15552000
10
+
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <good isSerialTrackable="false" buyPrice="41650.0" weight="3.2" volume="0.0" minPrice="0.0" uomUuid="19f1edc0-fc42-4001-94cb-c9ec9c62ec10" salePrice="300000.0" saleCurrencyUuid="2f7eb413-1666-11e4-9bee-002590a28eca" buyCurrencyUuid="2f7eb413-1666-11e4-9bee-002590a28eca" archived="false" parentUuid="eb576125-2e22-11e4-dd7b-002590a28eca" productCode="R006-P11-17" name="Кольцо Нимфа-2 малое с цирконами и жемчугом серебряное" updated="2014-11-25T14:52:08.066+03:00" updatedBy="admin@wannabejewelry" readMode="ALL" changeMode="NONE"><accountUuid>2f678846-1666-11e4-1e95-002590a28eca</accountUuid><accountId>2f678846-1666-11e4-1e95-002590a28eca</accountId><uuid>eb77ad57-2e22-11e4-4030-002590a28eca</uuid><code></code><externalcode>--7Hmbooi3KoVlMu7aOGV2</externalcode><description></description><attribute goodUuid="eb77ad57-2e22-11e4-4030-002590a28eca" metadataUuid="5abf49e6-7498-11e4-90a2-8ecb0038d40f" entityValueUuid="751b464c-7498-11e4-90a2-8ecb0038d853" updated="2014-11-25T14:52:07.429+03:00" updatedBy="admin@wannabejewelry" readMode="ALL" changeMode="NONE"><accountUuid>2f678846-1666-11e4-1e95-002590a28eca</accountUuid><accountId>2f678846-1666-11e4-1e95-002590a28eca</accountId><uuid>7f0831cf-7499-11e4-90a2-8ecb00390d2b</uuid></attribute><attribute goodUuid="eb77ad57-2e22-11e4-4030-002590a28eca" metadataUuid="54a59b46-7499-11e4-90a2-8ecb0039058c" valueText="test test" updated="2014-11-25T14:52:08.067+03:00" updatedBy="admin@wannabejewelry" readMode="ALL" changeMode="NONE"><accountUuid>2f678846-1666-11e4-1e95-002590a28eca</accountUuid><accountId>2f678846-1666-11e4-1e95-002590a28eca</accountId><uuid>6e9bda3c-7499-11e4-90a2-8ecb00390a08</uuid></attribute><attribute goodUuid="eb77ad57-2e22-11e4-4030-002590a28eca" metadataUuid="ffdf0643-7493-11e4-90a2-8ecb0037b75b" entityValueUuid="d3f18c9e-7493-11e4-90a2-8ecb0037ae75" updated="2014-11-25T14:38:48.876+03:00" updatedBy="admin@wannabejewelry" readMode="ALL" changeMode="NONE"><accountUuid>2f678846-1666-11e4-1e95-002590a28eca</accountUuid><accountId>2f678846-1666-11e4-1e95-002590a28eca</accountId><uuid>a30eb457-7497-11e4-90a2-8ecb0038ae7b</uuid></attribute><salePrices><price currencyUuid="2f7eb413-1666-11e4-9bee-002590a28eca" priceTypeUuid="2f7ee9c7-1666-11e4-5b14-002590a28eca" value="300000.0" readMode="ALL" changeMode="ALL"><accountUuid>2f678846-1666-11e4-1e95-002590a28eca</accountUuid><accountId>2f678846-1666-11e4-1e95-002590a28eca</accountId><uuid>eb77b286-2e22-11e4-545e-002590a28eca</uuid></price></salePrices><preferences/><images/></good>
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <good isSerialTrackable="false" weight="0.0" volume="0.0" supplierUuid="c64b1466-a5a2-11e5-7a69-97110001b177" minPrice="0.0" salePrice="499000.0" buyPrice="0.0" archived="false" parentUuid="951a2697-a5a0-11e5-7a69-971100010422" productCode="AJ-001-M-B/Bl/O" name="Nike air jordan 4 NEW 5" updated="2015-12-20T14:02:15.338+03:00" updatedBy="admin@bronx">
3
+ <accountUuid>1539f44c-a412-11e5-7a69-9711000014a3</accountUuid>
4
+ <accountId>1539f44c-a412-11e5-7a69-9711000014a3</accountId>
5
+ <uuid>0779df4f-a5a1-11e5-7a69-93a700078b39</uuid>
6
+ <groupUuid>153a5ed2-a412-11e5-7a69-9711000014a4</groupUuid>
7
+ <ownerUid>admin@bronx</ownerUid>
8
+ <shared>true</shared>
9
+ <code>5728</code>
10
+ <externalcode>5728</externalcode>
11
+ <description/>
12
+ <salePrices>
13
+ <price priceTypeUuid="155b00d1-a412-11e5-7a69-8f5500135f57" value="499000.0">
14
+ <accountUuid>1539f44c-a412-11e5-7a69-9711000014a3</accountUuid>
15
+ <accountId>1539f44c-a412-11e5-7a69-9711000014a3</accountId>
16
+ <uuid>0779e72a-a5a1-11e5-7a69-93a700078b3d</uuid>
17
+ <groupUuid>153a5ed2-a412-11e5-7a69-9711000014a4</groupUuid>
18
+ <ownerUid>admin@bronx</ownerUid>
19
+ <shared>true</shared>
20
+ </price>
21
+ </salePrices>
22
+ <barcode barcode="2000000059280" barcodeType="EAN13">
23
+ <accountUuid>1539f44c-a412-11e5-7a69-9711000014a3</accountUuid>
24
+ <accountId>1539f44c-a412-11e5-7a69-9711000014a3</accountId>
25
+ <uuid>0779e5fc-a5a1-11e5-7a69-93a700078b3c</uuid>
26
+ <groupUuid>153a5ed2-a412-11e5-7a69-9711000014a4</groupUuid>
27
+ <ownerUid>admin@bronx</ownerUid>
28
+ <shared>true</shared>
29
+ </barcode>
30
+ <preferences/>
31
+ <images>
32
+ <image tinyUuid="fe686a63-a708-11e5-7a69-971100051bcf" created="2015-12-20T14:01:17.290+03:00" filename="715ef5cffd4c1a183cba3aadfe549fd2.png" miniatureUuid="fec2f1a9-a708-11e5-7a69-971100051bd6" name="715ef5cffd4c1a183cba3aadfe549fd2" updated="2015-12-20T14:01:17.290+03:00" updatedBy="admin@bronx">
33
+ <accountUuid>1539f44c-a412-11e5-7a69-9711000014a3</accountUuid>
34
+ <accountId>1539f44c-a412-11e5-7a69-9711000014a3</accountId>
35
+ <uuid>fe700e25-a708-11e5-7a69-971100051bd0</uuid>
36
+ <externalcode>VXgiz18ZgWNgMtS-BsdYU1</externalcode>
37
+ </image>
38
+ </images>
39
+ </good>
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 403 Forbidden
2
+ Server: nginx/1.6.2
3
+ Date: Tue, 30 Dec 2014 08:45:56 GMT
4
+ Content-Type: text/html;charset=utf-8
5
+ Content-Length: 1054
6
+ Connection: close
7
+ Vary: Accept-Encoding
8
+
9
+ <html><head><title>JBoss Web/7.2.0.Final - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 403 - </h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u></u></p><p><b>JBWEB000069: description</b> <u>JBWEB000123: Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.2.0.Final</h3></body></html>
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 401 Unauthorized
2
+ Server: nginx/1.6.2
3
+ Date: Tue, 30 Dec 2014 08:36:16 GMT
4
+ Content-Type: text/html;charset=utf-8
5
+ Content-Length: 1196
6
+ Connection: close
7
+ WWW-Authenticate: Basic realm="Your Realm Here"
8
+
9
+ <html><head><title>JBoss Web/7.2.0.Final - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 401 - Неправильный пароль или имя пользователя</h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u>Неправильный пароль или имя пользователя</u></p><p><b>JBWEB000069: description</b> <u>JBWEB000121: This request requires HTTP authentication.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.2.0.Final</h3></body></html>
@@ -0,0 +1,70 @@
1
+ HTTP/1.1 500 Internal Server Error
2
+ Server: nginx/1.6.2
3
+ Date: Tue, 30 Dec 2014 09:07:27 GMT
4
+ Content-Type: application/xml
5
+ Content-Length: 4999
6
+ Connection: close
7
+
8
+ <?xml version="1.0" encoding="UTF-8"?>
9
+ <error>
10
+ <uid>kiiiosk@wannabejewelry</uid>
11
+ <moment>20141230120727828</moment>
12
+ <message>Wrong type: Unknown2</message>
13
+ <stack>
14
+ <![CDATA[
15
+ java.lang.IllegalArgumentException: Wrong type: Unknown2
16
+ at com.lognex.sklad.back.ejb.exchange.rest.RestExchangeManagerUser.checkType(RestExchangeManagerUser.java:57)
17
+ at com.lognex.sklad.back.ejb.exchange.rest.RestExchangeManagerUser.access$000(RestExchangeManagerUser.java:42)
18
+ at com.lognex.sklad.back.ejb.exchange.rest.RestExchangeManagerUser$2.write(RestExchangeManagerUser.java:166)
19
+ at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:32)
20
+ at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:17)
21
+ at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117)
22
+ at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:104)
23
+ at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123)
24
+ at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250)
25
+ at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:602)
26
+ at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:528)
27
+ at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
28
+ at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
29
+ at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
30
+ at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
31
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
32
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
33
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
34
+ at com.lognex.sklad.back.common.web.EnsureMyCompanyFilter.doFilter(EnsureMyCompanyFilter.java:36)
35
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
36
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
37
+ at com.lognex.api.face.filters.ProfilerFilter.doFilter(ProfilerFilter.java:32)
38
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
39
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
40
+ at com.lognex.security.filter.BasicAuthFilter.doAuthFilter(BasicAuthFilter.java:88)
41
+ at com.lognex.security.filter.AuthFilter.doFilter(AuthFilter.java:114)
42
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
43
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
44
+ at com.lognex.api.core.context.IcFilter.doFilter(IcFilter.java:23)
45
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
46
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
47
+ at com.lognex.util.http.RemoteIpFilter.doFilter(RemoteIpFilter.java:663)
48
+ at com.lognex.util.http.RemoteIpFilter.doFilter(RemoteIpFilter.java:673)
49
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
50
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
51
+ at com.lognex.metrics.http.MetricsFilter.doFilter(MetricsFilter.java:60)
52
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
53
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
54
+ at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
55
+ at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
56
+ at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
57
+ at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
58
+ at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
59
+ at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
60
+ at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
61
+ at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
62
+ at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
63
+ at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
64
+ at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
65
+ at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
66
+ at java.lang.Thread.run(Thread.java:744)
67
+
68
+ ]]>
69
+ </stack>
70
+ </error>
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 401 Unauthorized
2
+ Server: nginx/1.6.2
3
+ Date: Tue, 30 Dec 2014 08:35:50 GMT
4
+ Content-Type: text/html;charset=utf-8
5
+ Content-Length: 1174
6
+ Connection: close
7
+ WWW-Authenticate: Basic realm="Your Realm Here"
8
+
9
+ <html><head><title>JBoss Web/7.2.0.Final - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 401 - Неверный формат имени пользователя</h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u>Неверный формат имени пользователя</u></p><p><b>JBWEB000069: description</b> <u>JBWEB000121: This request requires HTTP authentication.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.2.0.Final</h3></body></html>
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Client::Errors do
4
+ it 'should be loaded' do
5
+ expect(AmoCRM::Resources).to be_a Module
6
+
7
+ expect(AmoCRM::Resources.resources).to include(AmoCRM::Resources::Features)
8
+ end
9
+
10
+ describe 'catch errors' do
11
+
12
+ let(:resource) { AmoCRM::Resources::CustomEntityMetadata.new client: client }
13
+ let(:file) { raise 'not setted' }
14
+ let(:url) { 'http://fake.url/' }
15
+ let(:result) { Faraday.new( url ).get '/' }
16
+
17
+ subject do
18
+ described_class.build result
19
+ end
20
+
21
+ before do
22
+ #AmoCRM::Client::ParsedError
23
+ stub_request(:get, url).to_return File.new( './spec/fixtures/' + file + '.raw' )
24
+ end
25
+
26
+ context 'bad gateway' do
27
+ let(:file) { '502' }
28
+ let(:error) { AmoCRM::Client::BadGatewayError }
29
+ it { expect{subject}.to raise_error error }
30
+ end
31
+
32
+ context 'internal server error' do
33
+ let(:file) { '500' }
34
+ let(:error) { AmoCRM::Client::InternalServerError }
35
+ it { expect{subject}.to raise_error error }
36
+ end
37
+
38
+ context 'wrong_user' do
39
+ let(:file) { 'wrong_user' }
40
+
41
+ let(:error) { AmoCRM::Client::UnauthorizedError }
42
+
43
+ it { expect{subject}.to raise_error error }
44
+ end
45
+
46
+ context 'wrong_password' do
47
+ let(:file) { 'wrong_password' }
48
+ let(:error) { AmoCRM::Client::UnauthorizedError }
49
+
50
+ it { expect{subject}.to raise_error error }
51
+ end
52
+
53
+ context 'wrong_type' do
54
+ let(:file) { 'wrong_type' }
55
+ let(:error) { AmoCRM::Client::ParsedError }
56
+
57
+ it { expect{subject}.to raise_error error }
58
+ end
59
+
60
+ context 'resource_forbidden' do
61
+ let(:file) { 'resource_forbidden' }
62
+ let(:error) { AmoCRM::Client::ResourceForbidden }
63
+
64
+ it { expect{subject}.to raise_error error }
65
+ end
66
+
67
+ describe 'encoding' do
68
+ context 'forbidden' do
69
+ let(:file) { 'resource_forbidden' }
70
+
71
+ subject do
72
+ AmoCRM::Client::ResourceForbidden.new result
73
+ end
74
+
75
+ it { expect(subject.message).to eq '[403] JBWEB000065: HTTP Status 403 - ; JBWEB000123: Access to the specified resource has been forbidden.' }
76
+ it { expect(subject.message.encoding).to eq Encoding::UTF_8 }
77
+ end
78
+ context 'wront_type' do
79
+ let(:file) { 'wrong_type' }
80
+
81
+ subject do
82
+ AmoCRM::Client::ParsedError.new result
83
+ end
84
+
85
+ it { expect(subject.message).to eq 'Wrong type: Unknown2' }
86
+ it { expect(subject.message.encoding).to eq Encoding::UTF_8 }
87
+ end
88
+ context 'wrong_password' do
89
+ let(:file) { 'wrong_password' }
90
+
91
+ subject do
92
+ AmoCRM::Client::UnauthorizedError.new result
93
+ end
94
+
95
+ it { expect(subject.message).to eq '[401] JBWEB000065: HTTP Status 401 - Неправильный пароль или имя пользователя; JBWEB000121: This request requires HTTP authentication.' }
96
+ it { expect(subject.message.encoding).to eq Encoding::UTF_8 }
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::AttributeMetadata do
4
+ let(:metadata_resource) { AmoCRM::Resources::EmbeddedEntityMetadata.indexed client: client }
5
+ let(:subresource) { metadata_resource.subresource_by_name :GoodFolder }
6
+ let(:attribute_metadata) { subresource.items.first }
7
+
8
+ before do
9
+ stub_rest :EmbeddedEntityMetadata, :list, 0
10
+ stub_rest :CustomEntityMetadata, :list, 0
11
+ end
12
+
13
+ context do
14
+ subject { attribute_metadata.dictionatyMetadata universe }
15
+ it do
16
+ expect(subject).to be_a AmoCRM::Entities::CustomEntityMetadata
17
+ expect(subject.uuid).to eq attribute_metadata.dictionaryMetadataUuid
18
+ end
19
+ end
20
+
21
+ context do
22
+ subject { attribute_metadata.entityMetadata universe }
23
+
24
+ it do
25
+ expect(subject).to be_a AmoCRM::Entities::EmbeddedEntityMetadata
26
+ expect(subject.uuid).to eq attribute_metadata.entityMetadataUuid
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::Attribute do
4
+ let(:good_uuid) { 'eb77ad57-2e22-11e4-4030-002590a28eca' }
5
+
6
+ before do
7
+ stub_rest :Good, good_uuid
8
+ stub_rest :EmbeddedEntityMetadata, :list, 0
9
+ stub_rest :CustomEntity, :list, 0
10
+ end
11
+
12
+ let(:goods_resource) { AmoCRM::Resources::Goods.indexed client: client }
13
+ let(:good) { goods_resource.get good_uuid }
14
+
15
+ let(:attribute_with_id_custom) { good.attributes.first }
16
+ let(:attribute_with_text) { good.attributes.second }
17
+
18
+ it 'should get ' do
19
+ expect(good).to be_a AmoCRM::Entities::Good
20
+ end
21
+
22
+ describe 'аттрибут типа ID_CUSTOM' do
23
+ subject { attribute_with_id_custom }
24
+
25
+ it do
26
+ expect(subject.metadata(universe)).to be_a AmoCRM::Entities::AttributeMetadata
27
+ expect(subject.metadata(universe).name).to eq 'Вставки'
28
+ expect(subject.attributeName(universe)).to eq 'Вставки'
29
+ end
30
+
31
+ it do
32
+ expect(subject.get_value(universe)).to eq "Культ. жемчуг, куб. циркон"
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::Country do
4
+
5
+ before do
6
+ stub_rest :Country, :list, 0
7
+ end
8
+
9
+ let(:resource) { AmoCRM::Resources::Countries.indexed client: client }
10
+
11
+ describe do
12
+ let(:country) { resource.all.first }
13
+
14
+ subject { country }
15
+
16
+ it do
17
+ expect(subject).to be_a AmoCRM::Entities::Country
18
+ end
19
+
20
+ it 'unicoded xml' do
21
+ expect(subject.to_xml).to start_with '<?xml version="1.0" encoding="utf-8"?>'
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::CustomEntityMetadata do
4
+ before do
5
+ stub_rest :CustomEntityMetadata, :list, 0
6
+ stub_rest :CustomEntity, :list, 0
7
+ end
8
+
9
+ let(:resource) { AmoCRM::Resources::CustomEntityMetadata.indexed client: client }
10
+
11
+ describe do
12
+ let(:custom_entity_metadata) { resource.all.first }
13
+
14
+ subject { custom_entity_metadata }
15
+
16
+ it do
17
+ expect(subject).to be_a AmoCRM::Entities::CustomEntityMetadata
18
+ end
19
+
20
+ it 'unicoded xml' do
21
+ expect(subject.to_xml).to start_with '<?xml version="1.0" encoding="utf-8"?>'
22
+ end
23
+
24
+ context 'entities' do
25
+
26
+ it do
27
+ expect(subject.entities(universe)).to be_a Array
28
+ expect(subject.entities(universe).first).to be_a AmoCRM::Entities::CustomEntity
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::CustomEntity do
4
+
5
+ before do
6
+ stub_rest :CustomEntityMetadata, :list, 0
7
+ stub_rest :CustomEntity, :list, 0
8
+ end
9
+
10
+ let(:resource) { AmoCRM::Resources::CustomEntities.indexed client: client }
11
+
12
+ describe do
13
+ let(:custom_entity) { resource.all.first }
14
+
15
+ subject { custom_entity }
16
+
17
+ it do
18
+ expect(subject).to be_a AmoCRM::Entities::CustomEntity
19
+ end
20
+
21
+ it 'unicoded xml' do
22
+ expect(subject.to_xml).to start_with '<?xml version="1.0" encoding="utf-8"?>'
23
+ end
24
+
25
+ context 'entityMetadata' do
26
+
27
+ it do
28
+ expect(subject.entityMetadata(universe)).to be_a AmoCRM::Entities::CustomEntityMetadata
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe AmoCRM::Entities::CustomerOrderPosition do
4
+ context 'generate' do
5
+ subject {
6
+ p= AmoCRM::Entities::CustomerOrderPosition.new
7
+ p.vat = 18
8
+ p.basePrice = AmoCRM::Entities::Price.new
9
+ p.basePrice.sum = 123
10
+ p.reserve = true
11
+ p
12
+ }
13
+
14
+ it 'to_xml' do
15
+ expect(subject.to_xml).to be_a String
16
+ end
17
+
18
+ it 'to_s' do
19
+ expect(subject.to_s).to be_a String
20
+ end
21
+
22
+ it 'include xml' do
23
+ expect(subject.to_xml).to include '<?xml version="1.0" encoding="utf-8"?>'
24
+ end
25
+
26
+ it 'include customerOrderPosition' do
27
+ expect(subject.to_xml).to include "<customerOrderPosition"
28
+ end
29
+
30
+ it 'include basePrice' do
31
+ expect(subject.to_xml).to include "<basePrice"
32
+ end
33
+ end
34
+
35
+ end