Class: Washbullet::Pushable::File

Inherits:
Washbullet::Pushable show all
Defined in:
lib/washbullet/pushable/file.rb

Instance Attribute Summary

Attributes inherited from Washbullet::Pushable

#client, #identifier, #params, #receiver

Instance Method Summary collapse

Methods inherited from Washbullet::Pushable

#initialize, push, #receiver_type, #specify_receiver

Constructor Details

This class inherits a constructor from Washbullet::Pushable

Instance Method Details

#pushObject

Raises:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/washbullet/pushable/file.rb', line 4

def push
  raise MissingParameter unless params.keys == required_parameters

  file_name = params[:file_name]
  file_path = params[:file_path]

  upload_file(file_name, file_path) do |data|
    payload = {
      file_name: data['file_name'],
      file_type: data['file_type'],
      file_url:  data['file_url'],
      body:      params['body'],
      type:      type
    }

    payload = specify_receiver(payload)

    client.post('/v2/pushes', payload)
  end
end

#required_parametersObject



29
30
31
# File 'lib/washbullet/pushable/file.rb', line 29

def required_parameters
  i(file_name file_path body)
end

#typeObject



25
26
27
# File 'lib/washbullet/pushable/file.rb', line 25

def type
  :file
end