Class: NewStoreApi::CreateDataRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/create_data_request.rb

Overview

Create data request.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(content = nil, content_type = nil, ttl = SKIP) ⇒ CreateDataRequest

Returns a new instance of CreateDataRequest.



45
46
47
48
49
# File 'lib/new_store_api/models/create_data_request.rb', line 45

def initialize(content = nil, content_type = nil, ttl = SKIP)
  @content = content
  @content_type = content_type
  @ttl = ttl unless ttl == SKIP
end

Instance Attribute Details

#contentBinary

The file content to store.

Returns:

  • (Binary)


14
15
16
# File 'lib/new_store_api/models/create_data_request.rb', line 14

def content
  @content
end

#content_typeString

The media type of the content data.

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/create_data_request.rb', line 18

def content_type
  @content_type
end

#ttlInteger

Time to live in days, will be kept indefinitely if not set.

Returns:

  • (Integer)


22
23
24
# File 'lib/new_store_api/models/create_data_request.rb', line 22

def ttl
  @ttl
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/new_store_api/models/create_data_request.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  content = hash.key?('content') ? hash['content'] : nil
  content_type = hash.key?('content_type') ? hash['content_type'] : nil
  ttl = hash.key?('ttl') ? hash['ttl'] : SKIP

  # Create object from extracted values.
  CreateDataRequest.new(content,
                        content_type,
                        ttl)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/new_store_api/models/create_data_request.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['content'] = 'content'
  @_hash['content_type'] = 'content_type'
  @_hash['ttl'] = 'ttl'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/new_store_api/models/create_data_request.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
# File 'lib/new_store_api/models/create_data_request.rb', line 34

def self.optionals
  %w[
    ttl
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



73
74
75
76
77
# File 'lib/new_store_api/models/create_data_request.rb', line 73

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} content: #{@content.inspect}, content_type: #{@content_type.inspect}, ttl:"\
  " #{@ttl.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



67
68
69
70
# File 'lib/new_store_api/models/create_data_request.rb', line 67

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} content: #{@content}, content_type: #{@content_type}, ttl: #{@ttl}>"
end