bitrix24_cloud_api 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5159253f72c36ac996990d4c399611008be7fc5f
4
- data.tar.gz: 1e0a269fa6c15b2a19fb2ed2b4f44c939235f075
2
+ SHA256:
3
+ metadata.gz: b92169a6152fa854ee3bda27b04c58fd53af4d8106797b4d307ecfc8c8a6ce3e
4
+ data.tar.gz: 48246a7ad48ae1228cd533a45ae1c85a238170e042ad72ddb0ae6e02fdf3d033
5
5
  SHA512:
6
- metadata.gz: be7f8a8a9a625e993fc6da21543d8987fbe2f53185d3b5cf2e794044f83664afd9039335fddd7e6c45c5046efbc5c2414c41a604a5a7cba255647c2eca8600f5
7
- data.tar.gz: f0466a691abd36b383766c8af28fe5c39a1f71feb9ab541b39069af07a688fbc69601bd44aeac9c385d7b6acf209b2f4c2b1e21a07a735064006c47256d0e21d
6
+ metadata.gz: 906d484f88507ff7ac490753c3230b11e0b9fe80855ec5a314c0c73d3683818db8ec0945a85b0a2e83a3e476f3ca7d39a92a3e0ae926eaebb9042b3acdbd9454
7
+ data.tar.gz: 8f1c16284be468be1be707c215aa3281e47bcf0c3a131651e23b84173a61d2719f31ad90785f94b36d48f1f9439056d8850a93e4df3ebd3933d7387b17a4e65b
data/README.md CHANGED
@@ -50,7 +50,20 @@ To **refresh** oauth2 **access_token** use:
50
50
 
51
51
  it's response contains a hash with refreshed *oauth2 credentials*.
52
52
 
53
- If you already **have a valid access_token** add it to the client's attributes `@client.update(access_token: access_token)` or create a new client instance `@client = Bitrix24CloudApi::Client.new(access_token: access_token)`.
53
+ If you already **have a valid access_token** add it to the client's attributes `@client.update(access_token: access_token)` or create a new client instance
54
+ ```
55
+ @client = Bitrix24CloudApi::Client.new(access_token: access_token, endpoint: api_endpoint).
56
+ ```
57
+
58
+ ### Aliases
59
+
60
+ ```
61
+ B24 == Bitrix24CloudApi
62
+ B24_CRM == Bitrix24CloudApi::CRM
63
+ ```
64
+
65
+ So, `Bitrix24CloudApi::CRM::Lead.add(@client, params)` equals to `B24_CRM::Lead.add(@client, params)`.
66
+
54
67
 
55
68
  ### CRM
56
69
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
+ spec.metadata["source_code_uri"] = "https://github.com/nononoy/bitrix24_cloud_api"
21
22
 
22
23
  spec.add_runtime_dependency "oauth2", "~> 1.1"
23
24
  spec.add_runtime_dependency "httparty", "~> 0.13.7"
@@ -72,12 +72,17 @@ module Bitrix24CloudApi
72
72
 
73
73
  def make_get_request(path, params = {})
74
74
  params.merge!(auth: access_token)
75
- response = HTTParty.get(path, query: params)
75
+ response = HTTParty.get(path,
76
+ query: params,
77
+ query_string_normalizer: ->(query) { Bitrix24CloudApi::HashConversions.to_params(query) })
76
78
  check_response(response)
77
79
  end
78
80
 
79
81
  def make_post_request(path, params = {})
80
- response = HTTParty.post(path, body: params, query: {auth: access_token})
82
+ response = HTTParty.post(path,
83
+ body: params,
84
+ query: { auth: access_token },
85
+ query_string_normalizer: ->(query) { Bitrix24CloudApi::HashConversions.to_params(query) })
81
86
  check_response(response)
82
87
  end
83
88
 
@@ -0,0 +1,37 @@
1
+ module Bitrix24CloudApi
2
+ module HashConversions
3
+
4
+ def self.to_params(hash)
5
+ hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop
6
+ end
7
+
8
+ def self.normalize_param(key, value)
9
+ param = ''
10
+ stack = []
11
+
12
+ if value.respond_to?(:to_ary)
13
+ param << if value.empty?
14
+ "#{key}[]=&"
15
+ else
16
+ value.to_ary.map.with_index { |element, index| normalize_param("#{key}[#{index}]", element) }.join
17
+ end
18
+ elsif value.respond_to?(:to_hash)
19
+ stack << [key, value.to_hash]
20
+ else
21
+ param << "#{key}=#{ERB::Util.url_encode(value.to_s)}&"
22
+ end
23
+
24
+ stack.each do |parent, hash|
25
+ hash.each do |k, v|
26
+ if v.respond_to?(:to_hash)
27
+ stack << ["#{parent}[#{k}]", v.to_hash]
28
+ else
29
+ param << normalize_param("#{parent}[#{k}]", v)
30
+ end
31
+ end
32
+ end
33
+
34
+ param
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Bitrix24CloudApi
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -2,6 +2,7 @@ require "bitrix24_cloud_api/base"
2
2
  require "bitrix24_cloud_api/client"
3
3
  require "bitrix24_cloud_api/common_methods/common_methods"
4
4
  require "bitrix24_cloud_api/crm"
5
+ require "bitrix24_cloud_api/hash_conversions"
5
6
  require "bitrix24_cloud_api/aliases"
6
7
  require "bitrix24_cloud_api/version"
7
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitrix24_cloud_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viacheslav Gruzdov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2024-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -170,12 +170,14 @@ files:
170
170
  - lib/bitrix24_cloud_api/client.rb
171
171
  - lib/bitrix24_cloud_api/common_methods/common_methods.rb
172
172
  - lib/bitrix24_cloud_api/crm.rb
173
+ - lib/bitrix24_cloud_api/hash_conversions.rb
173
174
  - lib/bitrix24_cloud_api/version.rb
174
175
  homepage: https://github.com/nononoy/bitrix24_cloud_api
175
176
  licenses:
176
177
  - MIT
177
- metadata: {}
178
- post_install_message:
178
+ metadata:
179
+ source_code_uri: https://github.com/nononoy/bitrix24_cloud_api
180
+ post_install_message:
179
181
  rdoc_options: []
180
182
  require_paths:
181
183
  - lib
@@ -190,9 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
192
  - !ruby/object:Gem::Version
191
193
  version: '0'
192
194
  requirements: []
193
- rubyforge_project:
194
- rubygems_version: 2.5.1
195
- signing_key:
195
+ rubygems_version: 3.5.6
196
+ signing_key:
196
197
  specification_version: 4
197
198
  summary: Bitrix24 REST API on Ruby
198
199
  test_files: []