Class: Resources::SltcRegistration
Instance Attribute Summary
Attributes inherited from BaseResource
#options, #prompter
Instance Method Summary
collapse
#sltc_registration_id
#service_definition_id
#third_party_id
#initialize
Constructor Details
This class inherits a constructor from BaseResource
Instance Method Details
#complete ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/pvdgm-svc-client/resources/sltc_registration.rb', line 33
def complete
tp_id = third_party_id
sd_id = service_definition_id
reg_id = sltc_registration_id
params = {
third_party_id: tp_id,
service_definition_id: sd_id,
account_id: prompter.ask("\nAccount ID: ", Integer) { |q| q.validate = lambda { | a | is_valid_object?('Account', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Account ID" },
baseline_days: prompter.ask("\nNumber of days for baseline: ", Integer) { |q| q.default = 180; q.responses[:not_valid] = "\nNot a valid number of days" }
}
result = post("services/sltc_registrations/#{reg_id}/complete", params)
puts result.inspect
puts
end
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/pvdgm-svc-client/resources/sltc_registration.rb', line 49
def configure
tp_id = third_party_id
sd_id = service_definition_id
reg_id = sltc_registration_id
params = {
third_party_id: tp_id,
service_definition_id: sd_id,
account_id: prompter.ask("\nAccount ID: ", Integer) { |q| q.validate = lambda { | a | is_valid_object?('Account', a) }; q.responses[:ask_on_error] = :question; q.responses[:not_valid] = "\nNot a valid Account ID" },
configure_only: 'true'
}
result = post("services/sltc_registrations/#{reg_id}/complete", params)
puts result.inspect
puts
end
|
#list ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/pvdgm-svc-client/resources/sltc_registration.rb', line 8
def list
status = prompter.choose do | |
.prompt = "\nSelect the status to filter with: "
.choice('All', 'Specify no status') { -1 }
.choice('New', 'New registrations') { 0 }
.choice('Completed', 'Completed registrations') { 1 }
end
filter = status >= 0 ? "?status=#{status}" : ''
result = get("services/sltc_registrations#{filter}")
puts "\nSimpleLTC Registrations"
table = Terminal::Table.new headings: [ 'Status', 'Company Name', 'Initiated By', 'Created At' ] do |t|
result.each do | registration |
t << [ registration['status'],
registration['company_name'],
registration['initiated_by'],
registration['created_at'] ]
end
end
prompter.say table.to_s
puts
end
|