amo_crm 0.2.2
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/.gitignore +28 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +4 -0
- data/Guardfile +29 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +14 -0
- data/amo_crm.gemspec +41 -0
- data/dump_amocrm_account.rb +7 -0
- data/lib/amo_crm.rb +31 -0
- data/lib/amo_crm/client.rb +98 -0
- data/lib/amo_crm/client/error.rb +18 -0
- data/lib/amo_crm/client/errors.rb +16 -0
- data/lib/amo_crm/entities.rb +14 -0
- data/lib/amo_crm/entities/account.rb +7 -0
- data/lib/amo_crm/entities/attachment_document.rb +16 -0
- data/lib/amo_crm/entities/attribute.rb +71 -0
- data/lib/amo_crm/entities/attribute_metadata.rb +38 -0
- data/lib/amo_crm/entities/barcode.rb +19 -0
- data/lib/amo_crm/entities/base.rb +5 -0
- data/lib/amo_crm/entities/collection.rb +12 -0
- data/lib/amo_crm/entities/common.rb +15 -0
- data/lib/amo_crm/entities/common_object.rb +27 -0
- data/lib/amo_crm/entities/company.rb +30 -0
- data/lib/amo_crm/entities/company_concern.rb +20 -0
- data/lib/amo_crm/entities/consignment.rb +22 -0
- data/lib/amo_crm/entities/contact.rb +29 -0
- data/lib/amo_crm/entities/contract.rb +2 -0
- data/lib/amo_crm/entities/country.rb +10 -0
- data/lib/amo_crm/entities/custom_entity.rb +18 -0
- data/lib/amo_crm/entities/custom_entity_metadata.rb +36 -0
- data/lib/amo_crm/entities/custom_field.rb +6 -0
- data/lib/amo_crm/entities/custom_field_definition.rb +13 -0
- data/lib/amo_crm/entities/custom_field_value.rb +5 -0
- data/lib/amo_crm/entities/custom_fields.rb +24 -0
- data/lib/amo_crm/entities/custom_fields_definition.rb +4 -0
- data/lib/amo_crm/entities/customer_order.rb +51 -0
- data/lib/amo_crm/entities/customer_order_position.rb +22 -0
- data/lib/amo_crm/entities/embedded_entity_metadata.rb +18 -0
- data/lib/amo_crm/entities/error.rb +13 -0
- data/lib/amo_crm/entities/feature.rb +23 -0
- data/lib/amo_crm/entities/good.rb +34 -0
- data/lib/amo_crm/entities/good_folder.rb +10 -0
- data/lib/amo_crm/entities/good_ref.rb +12 -0
- data/lib/amo_crm/entities/image.rb +21 -0
- data/lib/amo_crm/entities/images.rb +10 -0
- data/lib/amo_crm/entities/lead.rb +28 -0
- data/lib/amo_crm/entities/my_company.rb +12 -0
- data/lib/amo_crm/entities/page.rb +5 -0
- data/lib/amo_crm/entities/price.rb +15 -0
- data/lib/amo_crm/entities/price_type.rb +13 -0
- data/lib/amo_crm/entities/sale_price.rb +18 -0
- data/lib/amo_crm/entities/sale_prices.rb +10 -0
- data/lib/amo_crm/entities/slot.rb +10 -0
- data/lib/amo_crm/entities/stock_to.rb +33 -0
- data/lib/amo_crm/entities/warehouse.rb +15 -0
- data/lib/amo_crm/entities/workflow.rb +11 -0
- data/lib/amo_crm/entities/workflow_state.rb +8 -0
- data/lib/amo_crm/entities/xml_fix.rb +14 -0
- data/lib/amo_crm/errors.rb +1 -0
- data/lib/amo_crm/resources.rb +18 -0
- data/lib/amo_crm/resources/account.rb +30 -0
- data/lib/amo_crm/resources/base.rb +149 -0
- data/lib/amo_crm/resources/companies.rb +27 -0
- data/lib/amo_crm/resources/contacts.rb +23 -0
- data/lib/amo_crm/resources/custom_entity_metadata.rb +18 -0
- data/lib/amo_crm/resources/custom_field.rb +28 -0
- data/lib/amo_crm/resources/embedded_entity_metadata.rb +20 -0
- data/lib/amo_crm/resources/embedded_entity_metadata_indexed.rb +7 -0
- data/lib/amo_crm/resources/indexed.rb +89 -0
- data/lib/amo_crm/resources/leads.rb +31 -0
- data/lib/amo_crm/resources/stock.rb +36 -0
- data/lib/amo_crm/resources/subresource.rb +21 -0
- data/lib/amo_crm/resources/where_filter.rb +26 -0
- data/lib/amo_crm/response.rb +7 -0
- data/lib/amo_crm/universe.rb +44 -0
- data/lib/amo_crm/version.rb +3 -0
- data/scripts/rest.sh +25 -0
- data/spec/fixtures/302.raw +15 -0
- data/spec/fixtures/400.raw +8 -0
- data/spec/fixtures/401.html +1 -0
- data/spec/fixtures/401_2.html +1 -0
- data/spec/fixtures/405.raw +9 -0
- data/spec/fixtures/500.raw +8 -0
- data/spec/fixtures/502.raw +8 -0
- data/spec/fixtures/Consignment_list_0.raw +14 -0
- data/spec/fixtures/Consignment_list_1000.raw +14 -0
- data/spec/fixtures/Country_list.raw +14 -0
- data/spec/fixtures/CustomEntityMetadata_list.raw +14 -0
- data/spec/fixtures/CustomEntity_list.raw +14 -0
- data/spec/fixtures/CustomEntity_list_bad_chars.raw +17 -0
- data/spec/fixtures/EmbeddedEntityMetadata_list.raw +15 -0
- data/spec/fixtures/Feature_list.raw +14 -0
- data/spec/fixtures/Feature_list_1000.raw +14 -0
- data/spec/fixtures/Good_WithManyAttributes.raw +13 -0
- data/spec/fixtures/Good_e932ebe1-2e22-11e4-9406-002590a28eca.raw +12 -0
- data/spec/fixtures/Good_eb77ad57-2e22-11e4-4030-002590a28eca.raw +12 -0
- data/spec/fixtures/Goods_list.raw +14 -0
- data/spec/fixtures/Metadata_list.raw +14 -0
- data/spec/fixtures/PriceType_list.raw +14 -0
- data/spec/fixtures/Stock.raw +11 -0
- data/spec/fixtures/Stock_showConsignments.raw +11 -0
- data/spec/fixtures/Uom_list.raw +14 -0
- data/spec/fixtures/Warehouse_list.raw +14 -0
- data/spec/fixtures/Workflow_list.raw +15 -0
- data/spec/fixtures/attribute_boolean.xml +6 -0
- data/spec/fixtures/attribute_dictionary.xml +5 -0
- data/spec/fixtures/attribute_double.xml +6 -0
- data/spec/fixtures/attribute_file.xml +12 -0
- data/spec/fixtures/attribute_long.xml +6 -0
- data/spec/fixtures/attribute_text.xml +5 -0
- data/spec/fixtures/attribute_time.xml +6 -0
- data/spec/fixtures/attribute_url.xml +6 -0
- data/spec/fixtures/bad_chars.xml +6 -0
- data/spec/fixtures/customer_order.xml +28 -0
- data/spec/fixtures/good_with_attributes.raw +12 -0
- data/spec/fixtures/good_with_image.xml +39 -0
- data/spec/fixtures/resource_forbidden.raw +9 -0
- data/spec/fixtures/wrong_password.raw +9 -0
- data/spec/fixtures/wrong_type.raw +70 -0
- data/spec/fixtures/wrong_user.raw +9 -0
- data/spec/lib/amocrm/client/errors_spec.rb +102 -0
- data/spec/lib/amocrm/entities/attribute_metadata_spec.rb +30 -0
- data/spec/lib/amocrm/entities/attribute_spec.rb +36 -0
- data/spec/lib/amocrm/entities/country_spec.rb +25 -0
- data/spec/lib/amocrm/entities/custom_entity_metadata_spec.rb +34 -0
- data/spec/lib/amocrm/entities/custom_entity_spec.rb +34 -0
- data/spec/lib/amocrm/entities/customer_order_position_spec.rb +35 -0
- data/spec/lib/amocrm/entities/customer_order_spec.rb +58 -0
- data/spec/lib/amocrm/entities/good_spec.rb +55 -0
- data/spec/lib/amocrm/resources/base_spec.rb +61 -0
- data/spec/lib/amocrm/resources/countries_spec.rb +22 -0
- data/spec/lib/amocrm/resources/custom_entity_metadata_spec.rb +13 -0
- data/spec/lib/amocrm/resources/embedded_entity_metadata_indexed_spec.rb +20 -0
- data/spec/lib/amocrm/resources/embedded_entity_metadata_spec.rb +11 -0
- data/spec/lib/amocrm/resources/good_folders_spec.rb +17 -0
- data/spec/lib/amocrm/resources/indexed_spec.rb +61 -0
- data/spec/lib/amocrm/resources/stock_spec.rb +63 -0
- data/spec/lib/amocrm/resources/subresource_spec.rb +13 -0
- data/spec/lib/amocrm/resources/warehouses_spec.rb +20 -0
- data/spec/lib/amocrm/resources/workflows_spec.rb +21 -0
- data/spec/lib/amocrm/resources_spec.rb +10 -0
- data/spec/lib/amocrm/universe_spec.rb +53 -0
- data/spec/lib/amocrm_spec.rb +8 -0
- data/spec/spec_helper.rb +106 -0
- data/spec/support/resource.rb +72 -0
- metadata +500 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class Companies < Base
|
|
3
|
+
def find
|
|
4
|
+
raise 'no such method'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def set_path
|
|
8
|
+
'company/set'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_path
|
|
12
|
+
'company/list'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def response_key
|
|
16
|
+
'contacts'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.entity_class
|
|
20
|
+
AmoCRM::Entities::Company
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.resource_name
|
|
24
|
+
:companies
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class Contacts < Base
|
|
3
|
+
def set_path
|
|
4
|
+
'contacts/set'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def list_path
|
|
8
|
+
'contacts/list'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def response_key
|
|
12
|
+
'contacts'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.entity_class
|
|
16
|
+
AmoCRM::Entities::Contact
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.resource_name
|
|
20
|
+
:contacts
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
# https://online.moysklad.ru/exchange/rest/ms/xml/CustomEntityMetadata/list
|
|
3
|
+
# Список аттрибутов, которые используются как свойства товара
|
|
4
|
+
class CustomEntityMetadata < Base
|
|
5
|
+
def self.entity_class
|
|
6
|
+
AmoCRM::Entities::CustomEntityMetadata
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.type
|
|
10
|
+
'CustomEntityMetadata'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.resource_name
|
|
14
|
+
:custom_entity_metadata
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class CustomField < Base
|
|
3
|
+
|
|
4
|
+
def all
|
|
5
|
+
page.items
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def find
|
|
9
|
+
raise 'no such method'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list_path
|
|
13
|
+
'accounts/current'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def pluralized_key_path
|
|
17
|
+
'account' # custom_fields
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.entity_class
|
|
21
|
+
AmoCRM::Entities::CustomField
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.resource_name
|
|
25
|
+
:custom_fields
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class EmbeddedEntityMetadata < Base
|
|
3
|
+
def self.entity_class
|
|
4
|
+
AmoCRM::Entities::EmbeddedEntityMetadata
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.type
|
|
8
|
+
'EmbeddedEntityMetadata'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.resource_name
|
|
12
|
+
:embedded_entity_metadata
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.indexed *args
|
|
16
|
+
AmoCRM::Resources::EmbeddedEntityMetadataIndexed.new new(*args)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require_relative 'where_filter'
|
|
2
|
+
|
|
3
|
+
module AmoCRM::Resources
|
|
4
|
+
class Indexed < SimpleDelegator
|
|
5
|
+
WrongEntriesCountError = Class.new StandardError
|
|
6
|
+
ObjectHaveNoUuidError = Class.new StandardError
|
|
7
|
+
|
|
8
|
+
include WhereFilter
|
|
9
|
+
|
|
10
|
+
def initialize resource
|
|
11
|
+
raise TypeError, 'resource должен быть AmoCRM::Resources::Base' unless resource.is_a? AmoCRM::Resources::Base
|
|
12
|
+
super resource
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Автоматически подгружает постранично данныез из API и возвращает их все сразу.
|
|
16
|
+
#
|
|
17
|
+
# @return [Array of AmoCRM::Entities::Base]
|
|
18
|
+
def all
|
|
19
|
+
@cached_list || pull_list
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Возвращает запрашивемую запись из кеша.
|
|
23
|
+
# Предварительно подгружает все записи через метод `all`
|
|
24
|
+
#
|
|
25
|
+
# @return Moyskald::Entities::Base
|
|
26
|
+
def find uuid
|
|
27
|
+
index[uuid]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Перечень uuid-ов всех элементов в ресуресе
|
|
31
|
+
#
|
|
32
|
+
# @return [Array of uuids]
|
|
33
|
+
def uuids
|
|
34
|
+
index.keys
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Неиндексированный ресурс
|
|
38
|
+
#
|
|
39
|
+
# @return AmoCRM::Resources::Base
|
|
40
|
+
def resource
|
|
41
|
+
__getobj__
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def values
|
|
47
|
+
index.values
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def index
|
|
51
|
+
pull_list unless @_index
|
|
52
|
+
@_index
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def pull_list
|
|
56
|
+
@cached_list = load_full_list
|
|
57
|
+
@_index = prepare_index @cached_list
|
|
58
|
+
@cached_list
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def load_full_list
|
|
62
|
+
start = 0
|
|
63
|
+
list = []
|
|
64
|
+
|
|
65
|
+
_page = nil
|
|
66
|
+
|
|
67
|
+
begin
|
|
68
|
+
_page = page start: start
|
|
69
|
+
list += _page.items
|
|
70
|
+
break if _page.items.empty?
|
|
71
|
+
start = list.count
|
|
72
|
+
end while start<_page.total
|
|
73
|
+
|
|
74
|
+
raise WrongEntriesCountError, "При загрузке коллекции в результате колиество не совпадает с total: #{list.count}<>#{_page.total}" unless list.count==_page.total
|
|
75
|
+
|
|
76
|
+
list
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def prepare_index cached_list
|
|
80
|
+
i={}
|
|
81
|
+
cached_list.each do |r|
|
|
82
|
+
raise ObjectHaveNoUuidError, "У объекта нет uuid: #{r.to_xml}" unless r.respond_to?(:uuid) && r.uuid
|
|
83
|
+
i[r.uuid]=r
|
|
84
|
+
end
|
|
85
|
+
return i
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class Leads < Base
|
|
3
|
+
def all
|
|
4
|
+
page.items
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def find
|
|
8
|
+
raise 'no such method'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def set_path
|
|
12
|
+
'leads/set'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def list_path
|
|
16
|
+
'leads/list'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def response_key
|
|
20
|
+
'leads'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.entity_class
|
|
24
|
+
AmoCRM::Entities::Lead
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.resource_name
|
|
28
|
+
:leads
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module AmoCRM::Resources
|
|
2
|
+
class Stock < Base
|
|
3
|
+
|
|
4
|
+
def listWithConsignments params={}
|
|
5
|
+
list params.merge(showConsignments: true)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def all
|
|
9
|
+
page.items
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def find
|
|
13
|
+
raise 'no such method'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def list_path
|
|
17
|
+
'exchange/rest/stock/xml'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.entity_class
|
|
21
|
+
AmoCRM::Entities::StockTO
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.resource_name
|
|
25
|
+
:stock
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def parse_page content
|
|
31
|
+
items = AmoCRM::Entities::StockTO.parse content
|
|
32
|
+
AmoCRM::Entities::Page.new items, items.count, 0, items.count
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative 'where_filter'
|
|
2
|
+
module AmoCRM::Resources
|
|
3
|
+
class Subresource < Struct.new(:items)
|
|
4
|
+
include WhereFilter
|
|
5
|
+
|
|
6
|
+
def find uuid
|
|
7
|
+
findWhere uuid: uuid
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def all
|
|
11
|
+
items
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def values
|
|
17
|
+
items
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module AmoCRM::Resources::WhereFilter
|
|
2
|
+
|
|
3
|
+
# Возвращает список элементов по переданному фильтру.
|
|
4
|
+
# Например:
|
|
5
|
+
# > universe.features.where goodUuid: uuid
|
|
6
|
+
#
|
|
7
|
+
# @return [Array of AmoCRM::Entities::Base]
|
|
8
|
+
#
|
|
9
|
+
def where filter
|
|
10
|
+
values.select { |v| filtered? v, filter }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Возвращает первый найденный по фильтру элемент или
|
|
14
|
+
# nil
|
|
15
|
+
#
|
|
16
|
+
# @return AmoCRM::Entities::Base || nil
|
|
17
|
+
def findWhere filter
|
|
18
|
+
where(filter).first
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def filtered? o, filter={}
|
|
24
|
+
filter.select { |k,v| o.send(k)==v }.count == filter.keys.count
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'hashie'
|
|
2
|
+
|
|
3
|
+
module AmoCRM
|
|
4
|
+
class Universe
|
|
5
|
+
|
|
6
|
+
cattr_reader :resources_list
|
|
7
|
+
attr_reader :client
|
|
8
|
+
|
|
9
|
+
# @param client[AmoCRM::Client]
|
|
10
|
+
def initialize client: nil
|
|
11
|
+
raise "Должен быть client[AmoCRM::Client]" unless client.is_a? AmoCRM::Client
|
|
12
|
+
@client = client
|
|
13
|
+
@resources={}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.client_class
|
|
17
|
+
Client
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Ленивое создание universe
|
|
21
|
+
#
|
|
22
|
+
# @param user_login
|
|
23
|
+
# @param user_hash
|
|
24
|
+
def self.build user_login: , user_hash: , url:
|
|
25
|
+
client = client_class.new url: url
|
|
26
|
+
client.authorize! user_login: user_login, user_hash: user_hash
|
|
27
|
+
new client: client
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@@resources_list = []
|
|
31
|
+
AmoCRM::Resources.resources.each do |resource_klass|
|
|
32
|
+
resource = resource_klass.resource_name.to_sym
|
|
33
|
+
fail "Already have such resource #{resource}" if @@resources_list.include? resource
|
|
34
|
+
@@resources_list << resource
|
|
35
|
+
define_method resource_klass.resource_name do
|
|
36
|
+
@resources[resource_klass.type] ||= resource_klass.indexed( client: client )
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def class_by_resource resource
|
|
41
|
+
"AmoCRM::Resources::#{resource.to_s.singularize.capitalize}".constantize
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/scripts/rest.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
# source ./tmp/test_env
|
|
3
|
+
resource=$1
|
|
4
|
+
action=$2
|
|
5
|
+
start=$3
|
|
6
|
+
|
|
7
|
+
if [ -z "$MS_LOGIN" ] || [ -z "$MS_PASSWORD" ]; then
|
|
8
|
+
echo "Утсановите переменные окружения MS_LOGIN и MS_PASSWORD"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
if [ -z "$resource" ]; then
|
|
13
|
+
echo "Запуск: rest.sh Resoruce [action]"
|
|
14
|
+
echo "Например: rest.sh Feature list"
|
|
15
|
+
exit 2
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
url="https://online.moysklad.ru/exchange/rest/ms/xml/$1/$2"
|
|
19
|
+
|
|
20
|
+
if [ "$action"=="list" ] && [ -n "$start" ]; then
|
|
21
|
+
url="$url?start=$start"
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
echo $url >&2
|
|
25
|
+
curl --max-redirs 3 -is -u $MS_LOGIN:$MS_PASSWORD $url
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
HTTP/1.1 302 Moved Temporarily
|
|
2
|
+
Server: nginx
|
|
3
|
+
Date: Thu, 13 Nov 2014 16:43:43 GMT
|
|
4
|
+
Content-Type: text/html
|
|
5
|
+
Content-Length: 154
|
|
6
|
+
Connection: keep-alive
|
|
7
|
+
Location: http://brandymint.ru/
|
|
8
|
+
|
|
9
|
+
<html>
|
|
10
|
+
<head><title>302 Found</title></head>
|
|
11
|
+
<body bgcolor="white">
|
|
12
|
+
<center><h1>302 Found</h1></center>
|
|
13
|
+
<hr><center>nginx</center>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
HTTP/1.1 400 Bad Request
|
|
2
|
+
Server: nginx/1.6.1
|
|
3
|
+
Date: Thu, 13 Nov 2014 14:40:41 GMT
|
|
4
|
+
Content-Type: text/html;charset=utf-8
|
|
5
|
+
Content-Length: 1801
|
|
6
|
+
Connection: close
|
|
7
|
+
|
|
8
|
+
<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 400 - Unable to extract parameter from http request: javax.ws.rs.QueryParam("start") value is '' for public abstract javax.ws.rs.core.StreamingOutput com.lognex.sklad.back.ejb.exchange.rest.IRestExchangeManagerUser.entityList(java.lang.String,java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.Boolean)</h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u>Unable to extract parameter from http request: javax.ws.rs.QueryParam("start") value is '' for public abstract javax.ws.rs.core.StreamingOutput com.lognex.sklad.back.ejb.exchange.rest.IRestExchangeManagerUser.entityList(java.lang.String,java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.String,java.lang.String,java.lang.Boolean,java.lang.Boolean)</u></p><p><b>JBWEB000069: description</b> <u>JBWEB000120: The request sent by the client was syntactically incorrect.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.2.0.Final</h3></body></html>
|