Class: Gophish::Campaign
- Inherits:
-
Base
- Object
- Base
- Gophish::Campaign
show all
- Defined in:
- lib/gophish/campaign.rb
Defined Under Namespace
Classes: Event, Result
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all, configuration, delete, #destroy, find, get, #initialize, #new_record?, #persisted?, post, put, resource_name, resource_path, #save, #update_attributes
Constructor Details
This class inherits a constructor from Gophish::Base
Class Method Details
.complete(id) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/gophish/campaign.rb', line 57
def self.complete(id)
response = get "#{resource_path}/#{id}/complete"
raise StandardError, "Campaign not found with id: #{id}" if response.response.code != '200'
response.parsed_response
end
|
.get_results(id) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/gophish/campaign.rb', line 43
def self.get_results(id)
response = get "#{resource_path}/#{id}/results"
raise StandardError, "Campaign not found with id: #{id}" if response.response.code != '200'
response.parsed_response
end
|
.get_summary(id) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/gophish/campaign.rb', line 50
def self.get_summary(id)
response = get "#{resource_path}/#{id}/summary"
raise StandardError, "Campaign not found with id: #{id}" if response.response.code != '200'
response.parsed_response
end
|
Instance Method Details
#body_for_create ⇒ Object
39
40
41
|
# File 'lib/gophish/campaign.rb', line 39
def body_for_create
build_campaign_payload
end
|
#complete! ⇒ Object
72
73
74
75
76
|
# File 'lib/gophish/campaign.rb', line 72
def complete!
response = self.class.complete id
self.status = 'Completed' if response['success']
response
end
|
#completed? ⇒ Boolean
82
83
84
|
# File 'lib/gophish/campaign.rb', line 82
def completed?
status == 'Completed'
end
|
#get_results ⇒ Object
64
65
66
|
# File 'lib/gophish/campaign.rb', line 64
def get_results
self.class.get_results id
end
|
#get_summary ⇒ Object
68
69
70
|
# File 'lib/gophish/campaign.rb', line 68
def get_summary
self.class.get_summary id
end
|
#groups ⇒ Object
107
108
109
|
# File 'lib/gophish/campaign.rb', line 107
def groups
convert_to_instances super, Gophish::Group
end
|
#groups=(value) ⇒ Object
135
136
137
138
|
# File 'lib/gophish/campaign.rb', line 135
def groups=(value)
@groups_raw = value
super(convert_from_instances(value))
end
|
#has_send_by_date? ⇒ Boolean
90
91
92
|
# File 'lib/gophish/campaign.rb', line 90
def has_send_by_date?
!send_by_date.blank?
end
|
#in_progress? ⇒ Boolean
78
79
80
|
# File 'lib/gophish/campaign.rb', line 78
def in_progress?
status == 'In progress'
end
|
#launched? ⇒ Boolean
86
87
88
|
# File 'lib/gophish/campaign.rb', line 86
def launched?
!launch_date.blank?
end
|
#page ⇒ Object
99
100
101
|
# File 'lib/gophish/campaign.rb', line 99
def page
convert_to_instance super, Gophish::Page
end
|
#page=(value) ⇒ Object
125
126
127
128
|
# File 'lib/gophish/campaign.rb', line 125
def page=(value)
@page_raw = value
super(convert_from_instance(value))
end
|
#results ⇒ Object
111
112
113
|
# File 'lib/gophish/campaign.rb', line 111
def results
convert_to_instances super, Result
end
|
#results=(value) ⇒ Object
140
141
142
|
# File 'lib/gophish/campaign.rb', line 140
def results=(value)
super(convert_from_instances(value))
end
|
#smtp ⇒ Object
103
104
105
|
# File 'lib/gophish/campaign.rb', line 103
def smtp
convert_to_instance super, Gophish::Smtp
end
|
#smtp=(value) ⇒ Object
130
131
132
133
|
# File 'lib/gophish/campaign.rb', line 130
def smtp=(value)
@smtp_raw = value
super(convert_from_instance(value))
end
|
#template ⇒ Object
Custom getters to return proper class instances
95
96
97
|
# File 'lib/gophish/campaign.rb', line 95
def template
convert_to_instance super, Gophish::Template
end
|
#template=(value) ⇒ Object
Custom setters to handle both instances and hashes
120
121
122
123
|
# File 'lib/gophish/campaign.rb', line 120
def template=(value)
@template_raw = value
super(convert_from_instance(value))
end
|
#timeline ⇒ Object
115
116
117
|
# File 'lib/gophish/campaign.rb', line 115
def timeline
convert_to_instances super, Event
end
|
#timeline=(value) ⇒ Object
144
145
146
|
# File 'lib/gophish/campaign.rb', line 144
def timeline=(value)
super(convert_from_instances(value))
end
|