business-central 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb391f19d6cbf2649ddbe7eb0cf937d2657c140de32d6f6a8c1f92483a353f57
4
- data.tar.gz: c9ad222424c8b46bd9cdc4e282e5b583b2e795d1e1917c942b7da259e8380c92
3
+ metadata.gz: 8a9fce53948fe9fcc7fead040e9f2a3c11df882dc59ebe5db8add78fe4b9c396
4
+ data.tar.gz: 34c62baa8d371b776fae566c97c935467c7c3ee86cd2d3d36c4a22824257c16e
5
5
  SHA512:
6
- metadata.gz: 3413af99b793f31b5913c726dd7fc3f5c48328f39321809b35da46f62100a12b529996eadfd3191d1581c52a718d749fa7eb2b808eb3f063f7a2e9c05975967e
7
- data.tar.gz: 5e96d79316386187618b362f3ea365f2f510b50622a50f2436ec45feaa32d435e839fcbf4ac20b8c7bb8dc8b33e98a5a7295b2d9beeac7257bd4f1d5e6a4aca5
6
+ metadata.gz: 2d2acefa8f9086e59343fa0d25ff74f3c9782f20ac719983c5fcbc958ccaaf15fdd1ff28c9defd087d096ed89eb4ecc990c2a1e5e815f24f49217defba06fae3
7
+ data.tar.gz: f0978a52503c33b618a8d8a6df09c112dc0d4457c3665d67945de478d8ceb5e5e84a9b216d8190f016be62da92b2e5d521890f0532bc4a4d0bd1ee69aa91edfa
@@ -35,7 +35,9 @@ module BusinessCentral
35
35
  private
36
36
 
37
37
  def process
38
- if @response.is_a?(Array)
38
+ if @response.is_a?(String)
39
+ @results = @response
40
+ elsif @response.is_a?(Array)
39
41
  @results = []
40
42
  @response.each do |data|
41
43
  @results << convert(data)
@@ -4,7 +4,7 @@ module BusinessCentral
4
4
  module Object
5
5
  module URLHelper
6
6
  def encode_url_object(object)
7
- URI.encode(object)
7
+ URI::RFC2396_Parser.new.escape(object)
8
8
  end
9
9
 
10
10
  def encode_url_params(query)
@@ -21,6 +21,18 @@ module BusinessCentral
21
21
 
22
22
  def replace_template_with_value(query, values)
23
23
  query = query.dup
24
+ return replace_template_with_hash_values(query, values) if values.first.is_a?(Hash)
25
+ replace_template_with_array_values(query, values)
26
+ end
27
+
28
+ def replace_template_with_hash_values(query, values)
29
+ values.first.each do |key, value|
30
+ query.gsub!(/:#{key}/, odata_encode(value))
31
+ end
32
+ query
33
+ end
34
+
35
+ def replace_template_with_array_values(query, values)
24
36
  query.scan(/\?/).each_with_index do |_character, index|
25
37
  character_position = query =~ /\?/
26
38
  query[character_position] = odata_encode(values[index])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BusinessCentral
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
5
5
  end
@@ -43,4 +43,9 @@ class BusinessCentral::Object::ResponseTest < Minitest::Test
43
43
  request = BusinessCentral::Object::Response.new(params).results
44
44
  assert request.key?(:item)
45
45
  end
46
+
47
+ def test_string_response
48
+ response = BusinessCentral::Object::Response.new('{ "value": "OK - Action was successful" }')
49
+ assert_equal 'OK - Action was successful', response.results
50
+ end
46
51
  end
@@ -14,11 +14,16 @@ class BusinessCentral::WebServiceTest < Minitest::Test
14
14
  assert_equal @web_service.object_url, 'Company/Vendors'
15
15
  end
16
16
 
17
- def test_build_object_url_with_template_values
17
+ def test_build_object_url_with_array_template_values
18
18
  @web_service.object("Company('?')", 'business1')
19
19
  assert_equal @web_service.object_url, "Company('business1')"
20
20
  end
21
21
 
22
+ def test_build_object_url_with_hash_template_values
23
+ @web_service.object("Company(':business_name')", business_name: 'business1')
24
+ assert_equal @web_service.object_url, "Company('business1')"
25
+ end
26
+
22
27
  def test_object_get_request
23
28
  stub_request(:get, /Company/)
24
29
  .to_return(
@@ -92,4 +97,4 @@ class BusinessCentral::WebServiceTest < Minitest::Test
92
97
 
93
98
  assert @web_service.object("Company('?')", test_company_name).delete
94
99
  end
95
- end
100
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business-central
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrad Muir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '5.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '5.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-focus
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.2
61
+ version: '1.2'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.2
68
+ version: '1.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest-reporters
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.4.2
75
+ version: '1.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.4.2
82
+ version: '1.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.18.0
103
+ version: '0.21'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.18.0
110
+ version: '0.21'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.8'
117
+ version: '3.12'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.8'
124
+ version: '3.12'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: oauth2
127
127
  requirement: !ruby/object:Gem::Requirement