Class: ZuoraInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/zuora_interface.rb

Instance Method Summary collapse

Instance Method Details

#amend(amend) ⇒ Object



138
139
140
# File 'lib/zuora_interface.rb', line 138

def amend(amend)
  return @z.amend(amend)
end

#api_call(call, *args) ⇒ Object



103
104
105
# File 'lib/zuora_interface.rb', line 103

def api_call(call, *args)
  SysTimer.timeout(120) { self.send(call, *args) }
end

#create(objs) ⇒ Object



115
116
117
# File 'lib/zuora_interface.rb', line 115

def create(objs)
  return @z.create(objs)
end

#create_active_account(name) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/zuora_interface.rb', line 56

def (name)

  val = false
  session_start
   = (name)
  result = create([])
#    puts result.first.inspect

  if result.first.success

    accountId = result.first.id
    payment = make_payment_method(accountId)
    result = create([payment])

    if result.first.success

      paymentId = result.first.id
      con = make_contact(accountId)
      result = create([con])

      if result.first.success
        conId = result.first.id

        .id = accountId
        .status = 'Active'
        .billToId = conId
        .soldToId = conId
        result = update([])

        if result.first.success
          val = 
        else
          add_errors(result)
        end

      else
        add_errors(result)
      end
    else
      add_errors(result)
    end
  else
    add_errors(result)
  end
  return val
end

#delete(type, ids) ⇒ Object



127
128
129
130
131
132
# File 'lib/zuora_interface.rb', line 127

def delete(type, ids)
  d = ZUORA::Delete.new
  d.type = type
  d.ids = ids
  return @z.delete(d)
end

#driverObject



164
165
166
# File 'lib/zuora_interface.rb', line 164

def driver
  get_driver
end

#generate(objs) ⇒ Object



119
120
121
# File 'lib/zuora_interface.rb', line 119

def generate(objs)
  return @z.generate(objs)
end

#get_driverObject



160
161
162
# File 'lib/zuora_interface.rb', line 160

def get_driver
  @z ||= Zuora::Billing::Api.instance.driver
end

#get_object(query) ⇒ Object



142
143
144
145
146
147
148
149
# File 'lib/zuora_interface.rb', line 142

def get_object(query)
  object = lookup(query)
  unless object.result.size == 0
    return object.result.records.first
  else
    return nil
  end
end

#get_object_array(query) ⇒ Object



151
152
153
154
155
156
157
158
# File 'lib/zuora_interface.rb', line 151

def get_object_array(query)
  object = lookup(query)
  unless object.result.size == 0
    return object.result.records
  else
    return []
  end
end

#loginObject



168
169
170
171
172
173
174
# File 'lib/zuora_interface.rb', line 168

def 
  loginargs = ZUORA::.new
  loginargs.username = $ZUORA_USER
  loginargs.password = $ZUORA_PASSWORD
  @session = ZUORA::SessionHeader.new
  @session.session = @z.(loginargs).result.session
end

#make_account(accountName) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/zuora_interface.rb', line 12

def (accountName)
  acc = ZUORA::.new
  acc.allowInvoiceEdit = 0
  acc.name = accountName
  acc.currency = "USD"
  acc.autoPay = 0
  acc.status = "Draft"
  acc.paymentTerm = "Due Upon Receipt"
  acc.batch = "Batch1"
  acc.billCycleDay = "01"
  return acc
end

#make_contact(accountId) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/zuora_interface.rb', line 25

def make_contact(accountId)
  con = ZUORA::Contact.new
  con.accountId = accountId
  con.address1 = '4901 Morena Blvd';
  con.city = 'San Diego';
  con.country = 'United States';
  con.firstName = 'Robert';
  con.lastName = 'Smith';
  con.postalCode = '92117';
  con.state = 'Virginia';
  con.workEmail = '[email protected]';
  return con
end

#make_payment_method(accountId) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/zuora_interface.rb', line 39

def make_payment_method(accountId)
  pmt = ZUORA::PaymentMethod.new
  pmt.accountId = accountId
  pmt.creditCardAddress1 = '52 Vexford Lane';
  pmt.creditCardCity = 'Anaheim';
  pmt.creditCardCountry = 'United States';
  pmt.creditCardExpirationMonth = '12';
  pmt.creditCardExpirationYear = '2010';
  pmt.creditCardHolderName = 'Firstly Lastly';
  pmt.creditCardNumber = '4111111111111111';
  pmt.creditCardPostalCode = '22042';
  pmt.creditCardState = 'California';
  pmt.creditCardType = 'Visa';
  pmt.type = 'CreditCard';
  return pmt
end

#query(query_string) ⇒ Object



107
108
109
# File 'lib/zuora_interface.rb', line 107

def query(query_string)
  @z.query(ZUORA::Query.new(query_string))
end

#query_more(query_locator) ⇒ Object



111
112
113
# File 'lib/zuora_interface.rb', line 111

def query_more(query_locator)    
  @z.queryMore(ZUORA::QueryMore.new(query_locator))
end

#session_cleanupObject



185
186
187
# File 'lib/zuora_interface.rb', line 185

def session_cleanup
  @z.headerhandler.delete(@session) if @session
end

#session_start(custom_fields = {}) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/zuora_interface.rb', line 176

def session_start(custom_fields={})
  get_driver
  @z.do_init(custom_fields)
  session_cleanup
  
  @z.headerhandler.set @session
  @z.wiredump_dev = STDERR if $ZUORA_VERBOSE
end

#subscribe(sub) ⇒ Object



134
135
136
# File 'lib/zuora_interface.rb', line 134

def subscribe(sub)
  return @z.subscribe(sub)
end

#update(objs) ⇒ Object



123
124
125
# File 'lib/zuora_interface.rb', line 123

def update(objs)
  return @z.update(objs)
end