Class: ProcessOut::APIVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/api_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ APIVersion

Initializes the APIVersion object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



33
34
35
36
37
38
39
40
# File 'lib/processout/api_version.rb', line 33

def initialize(client, data = {})
  @client = client

  self.name = data.fetch(:name, nil)
  self.description = data.fetch(:description, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



13
14
15
# File 'lib/processout/api_version.rb', line 13

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



12
13
14
# File 'lib/processout/api_version.rb', line 12

def description
  @description
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/processout/api_version.rb', line 11

def name
  @name
end

Instance Method Details

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/processout/api_version.rb', line 59

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "description"
    self.description = data["description"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new APIVersion using the current client



43
44
45
# File 'lib/processout/api_version.rb', line 43

def new(data = {})
  APIVersion.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



79
80
81
82
83
84
85
86
87
88
# File 'lib/processout/api_version.rb', line 79

def prefill(data)
  if data.nil?
    return self
  end
  self.name = data.fetch(:name, self.name)
  self.description = data.fetch(:description, self.description)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



48
49
50
51
52
53
54
# File 'lib/processout/api_version.rb', line 48

def to_json(options)
  {
      "name": self.name,
      "description": self.description,
      "created_at": self.created_at,
  }.to_json
end