summaryrefslogtreecommitdiff
path: root/lib/Net/Indosoft/Voicebridge.pm
blob: e493af2f577f9acb30a9f7aebea42fc81c8cf24b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
package Net::Indosoft::Voicebridge;

use warnings;
use strict;
use Data::Dumper;
use SOAP::Lite;

our $AUTOLOAD;
our $DEBUG = 1;

=head1 NAME

Net::Indosoft::Voicebridge - Interface to Indosoft Voicebridge API

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';

=head1 SYNOPSYS

  use Net::Indosoft::Voicebridge;

  my $handle = Net::GlobalPOPs::MediaServicesAPI->new(
    'url'    => 'http://your_tag.kanobe.net:8080/vbsoap/voicebridgeAPI.php',
  );

=head1 METHODS

=head2 new

Creates a new Net::Indosoft::Voicebridge object.

=cut

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self = ref($_[0]) ? shift : { @_ };

#  my $soap = new SOAP::Lite (
#    'service' => $URL.'?wsdl',
#  );
#  $self->{soap} = $soap;

  bless($self, $class);
}

#ideally this could be retreived from the WSDL, but hey
# or at least derived from the method name?
our %requestobj = (
  'addAccount'       => 'Account',
  'modifyAccount'    => 'Account',
  'addClient'        => 'Client',
  'modifyClient'     => 'Client',
  'addConference'    => 'Conference',
  'modifyConference' => 'Conference',
);

#this is think they're just on crack.  returnning a string to parse inside
#a ton of XML?  somehow that misses the point.
our %returnparse = (
  'addAccount'       => [ qw( account_id ) ],
  'modifyAccount'    => [ qw( account_id ) ],
  'addClient'        => [ qw( client_id  ) ],
  'modifyClient'     => [ qw( client_id  ) ],
  'addConference'    => [ qw( conference_id moderator_pin participant_pin ) ],
  'modifyConference' => [ qw( conference_id ) ],
);

sub AUTOLOAD {
  my $self = shift;

  $AUTOLOAD =~ /(^|::)(\w+)$/ or die "unparsable AUTOLOAD: $AUTOLOAD";
  my $function = $2;
  return if $function eq 'DESTROY';

  my $uri = "voicebridgeAPI/$function";


  my $soap = SOAP::Lite
#    -> readable(1)
    -> proxy($self->{url})
#    -> on_action( sub { join '/', @_ } ) #according to the wsdl, right?
#    -> on_action( sub { "urn:voicebridgeAPI/$function" } )
    -> autotype(0)
#    -> default_ns("urn:voicebridgeAPI")
  ;

  my $request;
  my $obj = $requestobj{$function};
  if ( $obj ) {

    my $opts = ref($_[0]) ? shift : { @_ };
    if ( $DEBUG > 1 ) {
      warn "$_: ". $opts->{$_}. "\n" foreach keys %$opts;
    }

    $request = SOAP::Data->name( $obj =>
      \SOAP::Data->value(
        map SOAP::Data->name( $_ )->value( $opts->{$_} ), keys %$opts
      )
    );

  } else {

    $request = shift;

  }

  my $som = $soap->call( $function, $request );

  die $som->faultstring if $som->fault;
  return { 'error' => $som->faultdetail } if $som->fault;

  warn Dumper($som->body) if $DEBUG > 1;

  my $return = $som->valueof("//${function}Response/return");

  if ( $return =~ /^<errors/i ) {
    my $rsom = SOAP::Deserializer->deserialize($return);
    my @errors = $rsom->valueof('//errors/error');
    return { 'error' => join(' / ', @errors ) } if @errors;
  }

  if ( $function =~ /^delete/ && $return !~ /Deleted Success?fully/i ) {
    return { 'error'  => 'Deletion unsuccessful',
             'return' => $return,
           };
  }

  my %return = ( 'return'=>$return );
  foreach my $rp ( @{ $returnparse{$function} || [] } ) {
                              #are they always numeric?
    $return =~ /\W$rp\s*=\s*(\d+)/ and $return{$rp} = $1;
  }

  return \%return;
}

=head2 addAccount

Pass a list of key=>value pairs or a hash reference:

i.account_name: Required Field: Alpha Numeric 
ii.account_desc: Alpha Numeric
iii.account_addr: Alpha Numeric
iv.account_city: Alpha Numeric
v.account_state: Alpha Numeric
vi.account_country: Alpha Numeric
vii.account_zip: Alpha Numeric
viii.account_phone: Required Field: Alpha Numeric Ex: 123-123-1234
ix.account_fax: Alpha Numeric
x.account_email: Required Field, have to be in valid email format
xi.account_password: Required Field: Alpha Numeric

Returns a hash reference with one element, either 'error' for error conditions,
or 'account_id' if the account is created sucessfully.

=head2 modifyAccount

Pass a list of key=>value pairs or a hash reference:

xiv.account_id: Required Field (Provided when the account was created) 
xv.account_name: Required Field
xvi.account_desc 
xvii.account_addr 
xviii.account_city 
xix.account_state 
xx.account_country 
xxi.account_zip 
xxii.account_phone: Required Field 
xxiii.account_fax
xxiv.account_email: Required Field
xxv.account_password: Required Field

Returns a hash reference with one element, either 'error' for error conditions,
or 'account_id' if the account is modified sucessfully.

=head2 addClient

Pass a list of key=>value pairs or a hash reference:

account_id: Required Field Alpha Numeric 
client_contact_name: Required Field Alpha Numeric
client_contact_addr Alpha Numeric
client_contact_city Alpha Numeric
client_contact_state Alpha Numeric
client_contact_country Alpha Numeric
client_contact_zip Alpha Numeric
client_contact_phone: Required Field Alpha Numeric
client_contact_fax Alpha Numeric
client_contact_email: Required Field Alpha Numeric
client_contact_password: Required Field Alpha Numeric

Returns a hash reference with one element, either 'error' for error conditions,
or 'client_id' if the account is created sucessfully.

=head2 modifyClient

Pass a list of key=>value pairs or a hash reference:

client_id: Required Field
account_id: Required Field
client_contact_name: Required Field
client_contact_addr
client_contact_city
client_contact_state
client_contact_country
client_contact_zip
client_contact_phone: Required Field
client_contact_fax
client_contact_email: Required Field
client_contact_password: Required Field

Returns a hash reference with one element, either 'error' for error conditions,
or 'client_id' if the account is modified sucessfully.

=head2 addConference

Pass a list of key=>value pairs or a hash reference:

client_id: Required Field Alpha Numeric (Required to associate conference to client, client ID provided when new client is added)
conference_name: Required Field Alpha Numeric
conference_desc Alpha Numeric
start_time: Required Field Alpha Numeric
moderated_flag: 
1 ¿ Presentation mode 
0 ¿ Conversation Mode
entry_ann_flag: Integer
0 ¿ None
1 -  Tone
2 - Name 
record_flag: Integer
0 ¿ Stop Recording
1 ¿ Start Recording
moh_flag: Integer
0 ¿ Stop MOH
1 ¿ Start MOH
talk_detect_flag
play_user_cnt_flag: Integer
1- Announce number of conference members currently in conference
0 ¿ no Announcement
wait_for_admin_flag: Integer
1 - Only start conference once admin enters
0 ¿ all users without admin
stop_on_admin_exit_flag: Integer
1 - End conference when admin exits:
0 - No
second_pin_flag: Integer
1 - Prompt conference members for a second pin/password when logging in?
0 - No Extra conference PIN
secondary_pin: Integer
If second_pin_flag is 1 also pass the PIN
allow_sub_conf: Integer
1 ¿ Allow sub conference for this conference
0 ¿ Donot Allow sub conference
duration: Integer
Duration in minutes e.g 30 for 30 minutes
conference_type: reservationless/reserved

On errors, returns a hash reference with one element, 'error', otherwise
returns a hash reference with the following keys: conference_id, moderator_pin
and participant_pin.

=head2 modifyConference

Pass a list of key=>value pairs or a hash reference:

conference_id: Required Field
client_id: Required Field
conference_name: Required Field
conference_desc
start_time: Required Field
moderated_flag: 
1 ¿ Presentation mode 
0 ¿ Conversation Mode
entry_ann_flag: Integer
0 ¿ None
1 -  Tone
2 - Name 
record_flag: Integer
0 ¿ Stop Recording
1 ¿ Start Recording
moh_flag: Integer
0 ¿ Stop MOH
1 ¿ Start MOH
play_user_cnt_flag: Integer
1- Announce number of conference members currently in conference
0 ¿ no Announcement
wait_for_admin_flag: Integer
1 - Only start conference once admin enters
0 ¿ all users without admin
stop_on_admin_exit_flag: Integer
1 - End conference when admin exits:
0 - No
second_pin_flag: Integer
1 - Prompt conference members for a second pin/password when logging in?
0 - No Extra conference PIN
secondary_pin: Integer
If second_pin_flag is 1 also pass the PIN
allow_sub_conf: Integer
1 ¿ Allow sub conference for this conference
0 ¿ Donot Allow sub conference
duration: Integer
Duration in minutes e.g 30 for 30 minutes

Returns a hash reference with one element, either 'error' for error conditions,
or 'conference_id' if the conference is modified sucessfully.

=head2 deleteAccount

Pass a list of key=>value pairs or a hash reference:

i.account_id: Required Field

On errors, should returns a hash reference with one element, 'error'.

=head2 deleteClient

Pass a list of key=>value pairs or a hash reference:

ii.client_id: Required Field

On errors, should returns a hash reference with one element, 'error'.

=head2 deleteConference

Pass a list of key=>value pairs or a hash reference:

iii.conference_id: Required Field

On errors, should returns a hash reference with one element, 'error'.

=head1 The services below are not yet documented/online

=head2 addConferencePIN

=head2 modifyConferencePIN

=head2 deleteConferencePIN

=head2 addDNIS

=head2 modifyDNIS

=head2 deleteDNIS

=head1 AUTHOR

Ivan Kohler, C<< <ivan-voicebridge at freeside.biz> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-net-indosoft-voicebridge at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Indosoft-Voicebridge>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Net::Indosoft::Voicebridge

You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Indosoft-Voicebridge>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/Net-Indosoft-Voicebridge>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/Net-Indosoft-Voicebridge>

=item * Search CPAN

L<http://search.cpan.org/dist/Net-Indosoft-Voicebridge>

=back

=head1 ACKNOWLEDGEMENTS

This module was developed by Freeside Internet Services, Inc.
If you need a complete, open-source web-based application to manage your
customers, conferences, billing and trouble ticketing, please visit
http://freeside.biz/

Development sponsored by NxxTcom Conferencing.  If you need a cost-effective
voice, web or video conference, please visit http://www.nxxtcom.net/

=head1 COPYRIGHT & LICENSE

Copyright (c) 2009 Freeside Internet Services, Inc. <http://freeside.biz/>
All rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;