mks_common 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mks/common/methodresponse.rb +16 -18
- data/lib/mks/common/util.rb +9 -0
- data/lib/mks/common/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c80194251b33b0e31cac450309e3733bd4823b03e558249aabd5b803e9993ac
|
4
|
+
data.tar.gz: cb2bdd5da8b44fe4d2dd20e09532bcc611b7aeb9a63ed8d821950f16c4ff79e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c70e77cecf3a1d5efe2c6061cb57814e762f7379c5c5dc2d8e3aa145da87296826b1a604fae9a7226fedb6e1988b29d64d9f6a910d4f3887bcbdc6c479e70cd9
|
7
|
+
data.tar.gz: 2077e73e9c670add4b400b0b8886a45a520bd34daece364272b2209560fae6e890476b0c2ceced50c4197779797bcacaa4214008be803151173793a0f9298be4
|
@@ -5,7 +5,7 @@ module Mks
|
|
5
5
|
class MethodResponse
|
6
6
|
attr_accessor :success, :message, :data, :errors, :total
|
7
7
|
|
8
|
-
def initialize(success
|
8
|
+
def initialize(success=nil, message=nil, data=nil, errors=[], total=nil)
|
9
9
|
@success = success
|
10
10
|
@message = message
|
11
11
|
@data = data
|
@@ -13,25 +13,23 @@ module Mks
|
|
13
13
|
@total = total
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.error_response(data)
|
28
|
-
errors = data.is_a?(String) ? [data] : data.errors
|
29
|
-
return MethodResponse.new(false,nil, nil, errors, nil)
|
16
|
+
def self.from_json(json_response)
|
17
|
+
response = JSON.parse json_response
|
18
|
+
success = response['success'] if response.has_key?('success')
|
19
|
+
message = response['message'] if response.has_key?('message')
|
20
|
+
data = response['data'] if response.has_key?('data')
|
21
|
+
errors = response['errors'] if response.has_key?('errors')
|
22
|
+
total = response['total'] if response.has_key?('total')
|
23
|
+
MethodResponse.new(success, message, data, errors, total)
|
30
24
|
end
|
31
25
|
|
32
|
-
def
|
33
|
-
|
26
|
+
def to_hash
|
27
|
+
hash = {}
|
28
|
+
self.instance_variables.each do |var|
|
29
|
+
hash[var.to_s.delete("@")] = self.instance_variable_get var
|
30
|
+
end
|
31
|
+
return hash
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
37
|
-
end
|
35
|
+
end
|
data/lib/mks/common/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mks_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- bin/console
|
108
108
|
- bin/setup
|
109
109
|
- lib/mks/common/methodresponse.rb
|
110
|
+
- lib/mks/common/util.rb
|
110
111
|
- lib/mks/common/version.rb
|
111
112
|
- lib/mks_common.rb
|
112
113
|
- mks_common.gemspec
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: '0'
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.7.6
|
134
|
+
rubygems_version: 2.7.6.2
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: Common reusable classes for MKS
|