fix wa_tax_rate_update script to skip zero rates, #73226
[freeside.git] / bin / xmlrpc-agent_new_customer.pl
1 #!/usr/bin/perl
2 #
3 # xmlrpc-agent_new_customer.pl username password
4
5 use strict;
6 use Frontier::Client;
7 use Data::Dumper;
8
9 my( $username, $password ) = ( @ARGV );
10
11 my $uri = new URI 'http://localhost/selfservice/xmlrpc.cgi';
12
13 my $server = new Frontier::Client ( 'url' => $uri );
14
15
16 ###
17 #   login
18 ###
19
20 my $login_result = $server->call('FS.SelfService.XMLRPC.agent_login',
21   {
22     'username' => $username,
23     'password' => $username,
24   }
25 );
26
27 die $login_result->{'error'} if $login_result->{'error'};
28
29 my $session_id = $login_result->{'session_id'};
30 warn "logged in w/session_id $session_id\n";
31
32
33 ###
34 #   new_customer
35 ###
36
37 my $result = $server->call('FS.SelfService.XMLRPC.new_customer',
38   {
39     'session_id'     => $session_id,
40     #customer informaiton
41     'first'          => 'Tofu',
42     'last'           => 'Beast',
43     'address1'       => '1234 Soybean Ln.',
44     'city'           => 'Tofutown',
45     'state'          => 'CA',
46     'zip'            => '54321',
47     'country'        => 'US',
48     'invoicing_list' => 'tofu@example.com',
49     #billing information
50     'payby'          => 'CARD',
51     'payinfo'        => '4111111111111111',
52     'paycvv'         => '123',
53     'paydate'        => '11/2012',
54     #package information
55     'pkgpart'        => '2',
56     'username'       => 'tofu',
57     '_password'      => 's33kret',
58   }
59 );
60
61 die $result->{'error'} if $result->{'error'};
62
63 my $custnum = $result->{'custnum'};
64 warn "added new customer w/custnum $custnum\n";
65
66
67 ###
68 #   logout
69 ###
70
71 my $logout_result = $server->call('FS.SelfService.XMLRPC.agent_logout',
72   {
73     'session_id' => $session_id,
74   }
75 );
76
77 die $logout_result->{'error'} if $logout_result->{'error'};
78 warn "logged out\n";
79
80 1;