Class: FaxService

Inherits:
BaseService show all
Defined in:
lib/popbill/fax.rb

Overview

팝빌 팩스 API Service Implementation

Constant Summary

Constants inherited from BaseService

BaseService::BOUNDARY, BaseService::POPBILL_APIVersion, BaseService::ServiceID_REAL, BaseService::ServiceID_TEST, BaseService::ServiceURL_REAL, BaseService::ServiceURL_TEST

Instance Attribute Summary

Attributes inherited from BaseService

#isTest, #linkhub, #scopes, #token_table

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#addScope, #checkID, #checkIsMember, #getBalance, #getCorpInfo, #getPartnerBalance, #getPopbillURL, #getServiceID, #getServiceURL, #getSession_Token, #gzip_parse, #httpget, #httppost, #httppostfile, #httppostfiles, #joinMember, #listContact, #registContact, #setIsTest, #updateContact, #updateCorpInfo

Class Method Details

.instance(linkID, secretKey) ⇒ Object



7
8
9
10
11
12
# File 'lib/popbill/fax.rb', line 7

def instance(linkID, secretKey)
  super(linkID, secretKey)
  @instance ||= new
  @instance.addScope("160")
  return @instance
end

Instance Method Details

#cancelReserve(corpNum, receiptNum, userID = '') ⇒ Object



100
101
102
103
104
105
106
# File 'lib/popbill/fax.rb', line 100

def cancelReserve(corpNum, receiptNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  httpget("/FAX/#{receiptNum}/Cancel", corpNum, userID)
end

#getChargeInfo(corpNum, userID = '') ⇒ Object



16
17
18
19
20
21
# File 'lib/popbill/fax.rb', line 16

def getChargeInfo(corpNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  httpget("/FAX/ChargeInfo", corpNum, userID)
end

#getFaxDetail(corpNum, receiptNum, userID = '') ⇒ Object



92
93
94
95
96
97
98
# File 'lib/popbill/fax.rb', line 92

def getFaxDetail(corpNum, receiptNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  httpget("/FAX/#{receiptNum}", corpNum, userID)
end

#getUnitCost(corpNum, userID = '') ⇒ Object



30
31
32
33
34
35
# File 'lib/popbill/fax.rb', line 30

def getUnitCost(corpNum, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  httpget("/FAX/UnitCost", corpNum, userID)['unitCost']
end

#getURL(corpNum, togo, userID = '') ⇒ Object



23
24
25
26
27
28
# File 'lib/popbill/fax.rb', line 23

def getURL(corpNum, togo, userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end
  httpget("/FAX/?TG=#{togo}", corpNum, userID)['url']
end

#search(corpNum, sDate, eDate, state, reserveYN, senderOnly, page, perPage, order, userID = '') ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/popbill/fax.rb', line 37

def search(corpNum, sDate, eDate, state, reserveYN, senderOnly, page, perPage,
  order, userID = '')
  if corpNum.length != 10
        raise PopbillException.new('-99999999', '사업자등록번호가 올바르지 않습니다.')
  end
  if sDate.to_s == ''
    raise PopbillException.new('-99999999', '시작일자가 입력되지 않았습니다.')
  end
  if eDate.to_s == ''
    raise PopbillException.new('-99999999', '종료일자가 입력되지 않았습니다.')
  end

  uri = "/FAX/Search?SDate=#{sDate}&EDate=#{eDate}"
  uri += "&State=" + state.join(',')
  uri += "&ReserveYN=" + reserveYN
  uri += "&SenderOnly=" + senderOnly
  uri += "&Page=" + page.to_s
  uri += "&PerPage=" + perPage.to_s
  uri += "&Order=" + order

  httpget(URI.escape(uri), corpNum, userID)
end

#sendFax(corpNum, senderNum, senderName, receiverNum, receiverName, filePath, reserveDT = '', userID = '') ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/popbill/fax.rb', line 60

def sendFax(corpNum, senderNum, senderName, receiverNum, receiverName, filePath,
  reserveDT = '', userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  receiver = [
    {
      "rcv" => receiverNum,
      "rcvnm" => receiverName,
    }
  ]

  sendFax_multi(corpNum, senderNum, senderName, receiver, filePath, reserveDT, userID)
end

#sendFax_multi(corpNum, senderNum, senderName, receivers, filePaths, reserveDT = '', userID = '') ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/popbill/fax.rb', line 76

def sendFax_multi(corpNum, senderNum, senderName, receivers, filePaths,
  reserveDT = '', userID = '')
  if corpNum.length != 10
    raise PopbillException.new(-99999999, "사업자등록번호가 올바르지 않습니다.")
  end

  postData = {}
  postData["snd"] = senderNum
  postData["sndnm"] = senderName
  postData["fCnt"] = filePaths.length
  postData["sndDT"] = reserveDT
  postData["rcvs"] = receivers

  httppostfile("/FAX", corpNum, postData, filePaths, userID)['receiptNum']
end