Class: Passwordstate::Resources::Password
Instance Attribute Summary
#client
Class Method Summary
collapse
Instance Method Summary
collapse
acceptable_methods, api_path, #attributes, available?, delete, #get, get, index_field, #initialize, nil_as_string, passwordstate_to_ruby_field, passwordstateify_hash, post, #post, #pretty_print, #put, put, ruby_to_passwordstate_field, #stored?
Class Method Details
.all(client, **query) ⇒ Object
114
115
116
|
# File 'lib/passwordstate/resources/password.rb', line 114
def self.all(client, **query)
super client, **{ query_all: true }.merge(query)
end
|
.generate(client, **options) ⇒ Object
122
123
124
125
126
127
|
# File 'lib/passwordstate/resources/password.rb', line 122
def self.generate(client, **options)
results = client.request(:get, 'generatepassword', query: options).map { |r| r['Password'] }
return results.first if results.count == 1
results
end
|
.search(client, **query) ⇒ Object
118
119
120
|
# File 'lib/passwordstate/resources/password.rb', line 118
def self.search(client, **query)
super client, **{ _api_path: 'searchpasswords' }.merge(query)
end
|
Instance Method Details
#add_dependency(**data) ⇒ Object
108
109
110
111
112
|
# File 'lib/passwordstate/resources/password.rb', line 108
def add_dependency(**data)
raise 'Password dependency creation only available for stored passwords' unless stored?
client.request :post, 'dependencies', body: self.class.passwordstatify_hash(data.merge(password_id: password_id))
end
|
#check_in ⇒ Object
67
68
69
|
# File 'lib/passwordstate/resources/password.rb', line 67
def check_in
client.request :get, "passwords/#{password_id}", query: self.class.passwordstateify_hash(check_in: nil)
end
|
#delete(recycle: false, **query) ⇒ Object
104
105
106
|
# File 'lib/passwordstate/resources/password.rb', line 104
def delete(recycle: false, **query)
super(**query.merge(move_to_recycle_bin: recycle))
end
|
#history ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/passwordstate/resources/password.rb', line 90
def history
raise 'Password history only available on stored passwords' unless stored?
Passwordstate::ResourceList.new PasswordHistory,
client: client,
all_path: "passwordhistory/#{password_id}",
only: :all
end
|
#otp! ⇒ Object
63
64
65
|
# File 'lib/passwordstate/resources/password.rb', line 63
def otp!
client.request(:get, "onetimepassword/#{password_id}").first['OTP']
end
|
#permissions ⇒ Object
99
100
101
102
|
# File 'lib/passwordstate/resources/password.rb', line 99
def permissions
client.require_version('>= 8.4.8449')
PasswordPermission.new(_client: client, password_id: password_id)
end
|
#send_selfdestruct(email, expires_at:, view_count:, reason: nil, **params) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/passwordstate/resources/password.rb', line 71
def send_selfdestruct(email, expires_at:, view_count:, reason: nil, **params)
data = {
password_id: password_id,
to_email_address: email,
expires_at: expires_at,
no_views: view_count
}
data[:message] = params[:message] if params.key? :message
data[:prefix_message_content] = params[:prefix_message] if params.key? :prefix_message
data[:append_message_content] = params[:suffix_message] if params.key? :suffix_message
data[:to_first_name] = params[:name] if params.key? :name
data[:email_subject] = params[:subject] if params.key? :subject
data[:email_body] = params[:body] if params.key? :body
data[:passphrase] = params[:passphrase] if params.key? :passphrase
data[:reason] = reason if reason
client.request :post, 'selfdestruct', data: data
end
|