Class: LeanTesting::BugAttachmentsHandler

Inherits:
EntityHandler show all
Defined in:
lib/Handler/Bug/BugAttachmentsHandler.rb

Instance Method Summary collapse

Methods inherited from EntityHandler

#create, #delete, #find, #update

Constructor Details

#initialize(origin, bugID) ⇒ BugAttachmentsHandler

Returns a new instance of BugAttachmentsHandler.



4
5
6
7
8
# File 'lib/Handler/Bug/BugAttachmentsHandler.rb', line 4

def initialize(origin, bugID)
	super(origin)

	@bugID = bugID
end

Instance Method Details

#all(filters = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/Handler/Bug/BugAttachmentsHandler.rb', line 41

def all(filters = nil)
	if !filters
		filters = {}
	end

	super

	request = APIRequest.new(@origin, '/v1/bugs/' + @bugID.to_s() + '/attachments', 'GET')
	EntityList.new(@origin, request, BugAttachment, filters)
end

#upload(filepath) ⇒ Object

Uploads given file as an attachment for specified bug.

Arguments: filepath String – an absolute path of the file to be uploaded example: /home/path/to/file.txt (Linux), C:\Users\Documents\file.txt (Windows)

Exceptions: SDKInvalidArgException if filepath is not a string

Returns: BugAttachment – the newly uploaded attachment



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/Handler/Bug/BugAttachmentsHandler.rb', line 23

def upload(filepath)
	if !filepath.is_a? String
		raise SDKInvalidArgException, '`filepath` must be of type string'
	end

	req = APIRequest.new(
		@origin,
		'/v1/bugs/' + @bugID.to_s() + '/attachments',
		'POST',
		{
			'form_data' => true,
			'file_path' => filepath
		}
	)

	BugAttachment.new(@origin, req.exec)
end