Class: Junziqian::Interface::FileLinkRequest

Inherits:
BaseRequest
  • Object
show all
Defined in:
lib/junziqian/interface/file_link_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRequest

#content_type, #ignores_params

Constructor Details

#initialize(options = {}) ⇒ FileLinkRequest

Returns a new instance of FileLinkRequest.



8
9
10
11
12
13
# File 'lib/junziqian/interface/file_link_request.rb', line 8

def initialize options={}
  self.applyNo = options[:apply_no]
  self.storage_path = options[:storage_path] || '/tmp'
  self.file_name = options[:file_name] || "applyNo#{self.applyNo}.pdf"
  raise 'storage path not exist' unless File.exist?(storage_path)
end

Instance Attribute Details

#applyNoObject

Returns the value of attribute applyNo.



4
5
6
# File 'lib/junziqian/interface/file_link_request.rb', line 4

def applyNo
  @applyNo
end

#file_nameObject

Returns the value of attribute file_name.



6
7
8
# File 'lib/junziqian/interface/file_link_request.rb', line 6

def file_name
  @file_name
end

#storage_pathObject

Returns the value of attribute storage_path.



5
6
7
# File 'lib/junziqian/interface/file_link_request.rb', line 5

def storage_path
  @storage_path
end

Instance Method Details

#file_pathObject



30
31
32
# File 'lib/junziqian/interface/file_link_request.rb', line 30

def file_path
  storage_path
end

#ingore_signsObject



22
23
24
# File 'lib/junziqian/interface/file_link_request.rb', line 22

def ingore_signs
  []
end

#methodObject



18
19
20
# File 'lib/junziqian/interface/file_link_request.rb', line 18

def method
  'sign.link.file'
end

#query_paramsObject



26
27
28
# File 'lib/junziqian/interface/file_link_request.rb', line 26

def query_params
  {applyNo: applyNo}
end

#requestObject



36
37
38
39
40
41
42
43
44
# File 'lib/junziqian/interface/file_link_request.rb', line 36

def request
  result = Tool::RequestTool.do_post_by_requestObj(self)
  if result['success'] == true
    link = result['link']
    system(`curl '#{link}' -o #{file_path}/#{file_name}`)
  else
    'error'
  end
end

#versionObject



14
15
16
# File 'lib/junziqian/interface/file_link_request.rb', line 14

def version
  '1.0'
end