supportify_client 1.0.2 → 3.0.0

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.
@@ -1,21 +1,25 @@
1
+ require 'date'
2
+
1
3
  module Supportify
2
- #
3
- class User < BaseObject
4
- attr_accessor :id, :name
5
- # attribute mapping from ruby-style variable name to JSON key
4
+ class User
5
+ # Unique identifier for the user.
6
+ attr_accessor :id
7
+
8
+ # The name of the user.
9
+ attr_accessor :name
10
+
11
+ # Attribute mapping from ruby-style variable name to JSON key.
6
12
  def self.attribute_map
7
13
  {
8
14
 
9
- # Unique identifier for the user.
10
15
  :'id' => :'id',
11
16
 
12
- # The name of the user.
13
17
  :'name' => :'name'
14
18
 
15
19
  }
16
20
  end
17
21
 
18
- # attribute type
22
+ # Attribute type mapping.
19
23
  def self.swagger_types
20
24
  {
21
25
  :'id' => :'Integer',
@@ -25,7 +29,7 @@ module Supportify
25
29
  end
26
30
 
27
31
  def initialize(attributes = {})
28
- return if !attributes.is_a?(Hash) || attributes.empty?
32
+ return unless attributes.is_a?(Hash)
29
33
 
30
34
  # convert string to symbol for hash key
31
35
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
@@ -41,5 +45,114 @@ module Supportify
41
45
 
42
46
  end
43
47
 
48
+ # Check equality by comparing each attribute.
49
+ def ==(o)
50
+ return true if self.equal?(o)
51
+ self.class == o.class &&
52
+ id == o.id &&
53
+ name == o.name
54
+ end
55
+
56
+ # @see the `==` method
57
+ def eql?(o)
58
+ self == o
59
+ end
60
+
61
+ # Calculate hash code according to all attributes.
62
+ def hash
63
+ [id, name].hash
64
+ end
65
+
66
+ # build the object from hash
67
+ def build_from_hash(attributes)
68
+ return nil unless attributes.is_a?(Hash)
69
+ self.class.swagger_types.each_pair do |key, type|
70
+ if type =~ /^Array<(.*)>/i
71
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
72
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
73
+ else
74
+ #TODO show warning in debug mode
75
+ end
76
+ elsif !attributes[self.class.attribute_map[key]].nil?
77
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
78
+ else
79
+ # data not found in attributes(hash), not an issue as the data can be optional
80
+ end
81
+ end
82
+
83
+ self
84
+ end
85
+
86
+ def _deserialize(type, value)
87
+ case type.to_sym
88
+ when :DateTime
89
+ DateTime.parse(value)
90
+ when :Date
91
+ Date.parse(value)
92
+ when :String
93
+ value.to_s
94
+ when :Integer
95
+ value.to_i
96
+ when :Float
97
+ value.to_f
98
+ when :BOOLEAN
99
+ if value =~ /^(true|t|yes|y|1)$/i
100
+ true
101
+ else
102
+ false
103
+ end
104
+ when /\AArray<(?<inner_type>.+)>\z/
105
+ inner_type = Regexp.last_match[:inner_type]
106
+ value.map { |v| _deserialize(inner_type, v) }
107
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
108
+ k_type = Regexp.last_match[:k_type]
109
+ v_type = Regexp.last_match[:v_type]
110
+ {}.tap do |hash|
111
+ value.each do |k, v|
112
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
113
+ end
114
+ end
115
+ else # model
116
+ _model = Supportify.const_get(type).new
117
+ _model.build_from_hash(value)
118
+ end
119
+ end
120
+
121
+ def to_s
122
+ to_hash.to_s
123
+ end
124
+
125
+ # to_body is an alias to to_body (backward compatibility))
126
+ def to_body
127
+ to_hash
128
+ end
129
+
130
+ # return the object in the form of hash
131
+ def to_hash
132
+ hash = {}
133
+ self.class.attribute_map.each_pair do |attr, param|
134
+ value = self.send(attr)
135
+ next if value.nil?
136
+ hash[param] = _to_hash(value)
137
+ end
138
+ hash
139
+ end
140
+
141
+ # Method to output non-array value in the form of hash
142
+ # For object, use to_hash. Otherwise, just return the value
143
+ def _to_hash(value)
144
+ if value.is_a?(Array)
145
+ value.compact.map{ |v| _to_hash(v) }
146
+ elsif value.is_a?(Hash)
147
+ {}.tap do |hash|
148
+ value.each { |k, v| hash[k] = _to_hash(v) }
149
+ end
150
+ elsif value.respond_to? :to_hash
151
+ value.to_hash
152
+ else
153
+ value
154
+ end
155
+ end
156
+
44
157
  end
45
158
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: supportify_client 1.0.2 ruby lib
5
+ # stub: supportify_client 3.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "supportify_client"
9
- s.version = "1.0.2"
9
+ s.version = "3.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Jordan Yaker", "Supportify, Inc."]
14
- s.date = "2015-11-18"
14
+ s.date = "2016-01-23"
15
15
  s.description = "Supportify is the world's first Help Center as a Service that focuses on providing you with a smart help center to provide better help content in less time."
16
16
  s.email = "help@supportify.io"
17
17
  s.extra_rdoc_files = [
@@ -34,11 +34,12 @@ Gem::Specification.new do |s|
34
34
  "lib/supportify_client/api_client.rb",
35
35
  "lib/supportify_client/api_error.rb",
36
36
  "lib/supportify_client/configuration.rb",
37
- "lib/supportify_client/models/base_object.rb",
38
37
  "lib/supportify_client/models/category.rb",
39
38
  "lib/supportify_client/models/error.rb",
40
39
  "lib/supportify_client/models/faq.rb",
41
40
  "lib/supportify_client/models/info.rb",
41
+ "lib/supportify_client/models/info_application.rb",
42
+ "lib/supportify_client/models/info_supportify.rb",
42
43
  "lib/supportify_client/models/tag.rb",
43
44
  "lib/supportify_client/models/user.rb",
44
45
  "lib/supportify_client/version.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supportify_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Yaker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-18 00:00:00.000000000 Z
12
+ date: 2016-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
@@ -148,11 +148,12 @@ files:
148
148
  - lib/supportify_client/api_client.rb
149
149
  - lib/supportify_client/api_error.rb
150
150
  - lib/supportify_client/configuration.rb
151
- - lib/supportify_client/models/base_object.rb
152
151
  - lib/supportify_client/models/category.rb
153
152
  - lib/supportify_client/models/error.rb
154
153
  - lib/supportify_client/models/faq.rb
155
154
  - lib/supportify_client/models/info.rb
155
+ - lib/supportify_client/models/info_application.rb
156
+ - lib/supportify_client/models/info_supportify.rb
156
157
  - lib/supportify_client/models/tag.rb
157
158
  - lib/supportify_client/models/user.rb
158
159
  - lib/supportify_client/version.rb
@@ -1,87 +0,0 @@
1
- require 'date'
2
-
3
- module Supportify
4
- # base class containing fundamental method such as to_hash, build_from_hash and more
5
- class BaseObject
6
-
7
- # build the object from hash
8
- def build_from_hash(attributes)
9
- return nil unless attributes.is_a?(Hash)
10
- self.class.swagger_types.each_pair do |key, type|
11
- if type =~ /^Array<(.*)>/i
12
- if attributes[self.class.attribute_map[key]].is_a?(Array)
13
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
14
- else
15
- #TODO show warning in debug mode
16
- end
17
- elsif !attributes[self.class.attribute_map[key]].nil?
18
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
19
- else
20
- # data not found in attributes(hash), not an issue as the data can be optional
21
- end
22
- end
23
-
24
- self
25
- end
26
-
27
- def _deserialize(type, value)
28
- case type.to_sym
29
- when :DateTime
30
- DateTime.parse(value)
31
- when :Date
32
- Date.parse(value)
33
- when :String
34
- value.to_s
35
- when :Integer
36
- value.to_i
37
- when :Float
38
- value.to_f
39
- when :BOOLEAN
40
- if value =~ /^(true|t|yes|y|1)$/i
41
- true
42
- else
43
- false
44
- end
45
- else # model
46
- _model = Supportify.const_get(type).new
47
- _model.build_from_hash(value)
48
- end
49
- end
50
-
51
- def to_s
52
- to_hash.to_s
53
- end
54
-
55
- # to_body is an alias to to_body (backward compatibility))
56
- def to_body
57
- to_hash
58
- end
59
-
60
- # return the object in the form of hash
61
- def to_hash
62
- hash = {}
63
- self.class.attribute_map.each_pair do |key, value|
64
- if self.send(key).is_a?(Array)
65
- next if self.send(key).empty?
66
- hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
67
- else
68
- unless (_tmp_value = _to_hash self.send(key)).nil?
69
- hash[value] = _tmp_value
70
- end
71
- end
72
- end
73
- hash
74
- end
75
-
76
- # Method to output non-array value in the form of hash
77
- # For object, use to_hash. Otherwise, just return the value
78
- def _to_hash(value)
79
- if value.respond_to? :to_hash
80
- value.to_hash
81
- else
82
- value
83
- end
84
- end
85
-
86
- end
87
- end