Class: SuperSendTX::DomainsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/supersendtx/resources.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ DomainsResource

Returns a new instance of DomainsResource.



76
77
78
# File 'lib/supersendtx/resources.rb', line 76

def initialize(http)
  @http = http
end

Instance Method Details

#apply(id_or_name, provider: "cloudflare", credentials: nil) ⇒ Object



101
102
103
104
105
# File 'lib/supersendtx/resources.rb', line 101

def apply(id_or_name, provider: "cloudflare", credentials: nil)
  body = { "action" => "apply", "provider" => provider }
  body["credentials"] = credentials if credentials
  @http.request("POST", "/domains/#{URI.encode_www_form_component(id_or_name)}", body: body)
end

#create(name, inbound_enabled: nil) ⇒ Object



91
92
93
94
95
# File 'lib/supersendtx/resources.rb', line 91

def create(name, inbound_enabled: nil)
  body = { "name" => name }
  body["inbound_enabled"] = inbound_enabled unless inbound_enabled.nil?
  @http.request("POST", "/domains", body: body)
end

#delete(id_or_name) ⇒ Object



111
112
113
# File 'lib/supersendtx/resources.rb', line 111

def delete(id_or_name)
  @http.request("DELETE", "/domains/#{URI.encode_www_form_component(id_or_name)}")
end

#get(id_or_name) ⇒ Object



87
88
89
# File 'lib/supersendtx/resources.rb', line 87

def get(id_or_name)
  @http.request("GET", "/domains/#{URI.encode_www_form_component(id_or_name)}")
end

#list(limit: nil, cursor: nil, inbound_enabled: nil) ⇒ Object



80
81
82
83
84
85
# File 'lib/supersendtx/resources.rb', line 80

def list(limit: nil, cursor: nil, inbound_enabled: nil)
  @http.request(
    "GET",
    "/domains#{@http.query({ "limit" => limit, "cursor" => cursor, "inbound_enabled" => inbound_enabled })}"
  )
end

#update(id_or_name, **params) ⇒ Object



107
108
109
# File 'lib/supersendtx/resources.rb', line 107

def update(id_or_name, **params)
  @http.request("PATCH", "/domains/#{URI.encode_www_form_component(id_or_name)}", body: params)
end

#verify(id_or_name) ⇒ Object



97
98
99
# File 'lib/supersendtx/resources.rb', line 97

def verify(id_or_name)
  @http.request("POST", "/domains/#{URI.encode_www_form_component(id_or_name)}", body: { "action" => "verify" })
end