Class: ProcessOut::ProjectSFTPSettingsPublic

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the ProjectSFTPSettingsPublic 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/project_sftp_settings_public.rb', line 33

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

  self.enabled = data.fetch(:enabled, nil)
  self.endpoint = data.fetch(:endpoint, nil)
  self.username = data.fetch(:username, nil)
  
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

#endpointObject

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#fetch_sftp_settings(id, options = {}) ⇒ Object

Fetch the SFTP settings for the project. Params:

id

ID of the project

options

Hash of options



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/processout/project_sftp_settings_public.rb', line 94

def fetch_sftp_settings(id, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/projects/" + CGI.escape(id) + "/sftp-settings"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body["sftp_settings"]
  
  
  obj = ProjectSFTPSettingsPublic.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end

#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/project_sftp_settings_public.rb', line 59

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "enabled"
    self.enabled = data["enabled"]
  end
  if data.include? "endpoint"
    self.endpoint = data["endpoint"]
  end
  if data.include? "username"
    self.username = data["username"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new ProjectSFTPSettingsPublic using the current client



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

def new(data = {})
  ProjectSFTPSettingsPublic.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/project_sftp_settings_public.rb', line 79

def prefill(data)
  if data.nil?
    return self
  end
  self.enabled = data.fetch(:enabled, self.enabled)
  self.endpoint = data.fetch(:endpoint, self.endpoint)
  self.username = data.fetch(:username, self.username)
  
  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/project_sftp_settings_public.rb', line 48

def to_json(options)
  {
      "enabled": self.enabled,
      "endpoint": self.endpoint,
      "username": self.username,
  }.to_json
end