Class: Einvoice::Tradevan::Provider

Inherits:
Provider
  • Object
show all
Defined in:
lib/einvoice/tradevan/provider.rb

Instance Attribute Summary

Attributes inherited from Provider

#provider

Instance Method Summary collapse

Methods inherited from Provider

#config, #initialize

Constructor Details

This class inherits a constructor from Einvoice::Provider

Instance Method Details

#cancel(payload, options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/einvoice/tradevan/provider.rb', line 36

def cancel(payload, options = {})
  void_data = Einvoice::Tradevan::Model::VoidData.new
  void_data.from_json(payload.to_json)

  if void_data.valid?
    response = connection(
      ssl: {
        verify: false
      }
    ).post do |request|
      request.url endpoint_url || endpoint + "/DEFAULTAPI/post/cancel"
      request.params[:v] = encrypted_params(voidData: void_data.payload)
    end.body

    Einvoice::Tradevan::Result.new(response)
  else
    Einvoice::Tradevan::Result.new(void_data.errors)
  end
end

#get_donate_unit_list(companyUn, options = {}) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/einvoice/tradevan/provider.rb', line 121

def get_donate_unit_list(companyUn, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getDonateUnitList"
    request.params[:v] = encrypted_params(companyUn: companyUn)
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#get_invoice_content(payload, options = {}) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/einvoice/tradevan/provider.rb', line 134

def get_invoice_content(payload, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getInvoiceContent"
    request.params[:v] = encrypted_params(payload)
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#get_invoice_mark_info(payload, options = {}) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/einvoice/tradevan/provider.rb', line 108

def get_invoice_mark_info(payload, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getInvoiceMarkInfo"
    request.params[:v] = encrypted_params(payload)
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#issue(payload, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/einvoice/tradevan/provider.rb', line 16

def issue(payload, options = {})
  issue_data = Einvoice::Tradevan::Model::IssueData.new
  issue_data.from_json(payload.to_json)

  if issue_data.valid?
    response = connection(
      ssl: {
        verify: false
      }
    ).post do |request|
      request.url endpoint_url || endpoint + "/DEFAULTAPI/post/issue"
      request.params[:v] = encrypted_params(issueData: issue_data.payload)
    end.body

    Einvoice::Tradevan::Result.new(response)
  else
    Einvoice::Tradevan::Result.new(issue_data.errors)
  end
end

#search_invoice_by_member_id(payload, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/einvoice/tradevan/provider.rb', line 56

def search_invoice_by_member_id(payload, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceByMemberId"
    request.params[:v] = encrypted_params(payload)
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#search_invoice_by_transaction_number(payload, options = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/einvoice/tradevan/provider.rb', line 82

def search_invoice_by_transaction_number(payload, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceInfoByTransactionnumber"
    request.params[:v] = encrypted_params(payload.slice(:companyUn, :orgId, :transactionNumber))
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#search_invoice_detail(invoice_number) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/einvoice/tradevan/provider.rb', line 69

def search_invoice_detail(invoice_number)
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceDetail"
    request.params[:v] = encrypted_params(invoiceNumber: invoice_number)
  end.body

  Einvoice::Tradevan::Result.new(response)
end

#send_card_info_to_cust(payload, options = {}) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/einvoice/tradevan/provider.rb', line 95

def send_card_info_to_cust(payload, options = {})
  response = connection(
    ssl: {
      verify: false
    }
  ).get do |request|
    request.url endpoint_url || endpoint + "/DEFAULTAPI/get/sendCardInfotoCust"
    request.params[:v] = encrypted_params(payload)
  end.body

  Einvoice::Tradevan::Result.new(response)
end