summaryrefslogtreecommitdiff
path: root/fs_selfservice/java/freeside_signup_example.java
blob: 6c695c445a7bd3fc67baad1e1b63e1bb6f01892b (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

import biz.freeside.SelfService;
import org.apache.commons.logging.impl.SimpleLog; // included in apache xmlrpc
import java.util.HashMap;
import java.util.Vector;

public class freeside_signup_example {
  private static SimpleLog logger = new SimpleLog("SelfService");

  public static void main( String args[] ) throws Exception {
    SelfService client =
      new SelfService( "http://192.168.1.221:8081/xmlrpc.cgi" );

    Vector params = new Vector();
    params.addElement( "first" );
    params.addElement( "Test" );
    params.addElement( "last" );
    params.addElement( "User" );
    params.addElement( "address1");
    params.addElement( "123 Test Street" );
    params.addElement( "address2");
    params.addElement( "Suite A" );
    params.addElement( "city");
    params.addElement( "Testville" );
    params.addElement( "state");
    params.addElement( "OH" );
    params.addElement( "zip");
    params.addElement( "44632" );
    params.addElement( "country");
    params.addElement( "US" );
    params.addElement( "daytime" );
    params.addElement( "216-412-1234" );
    params.addElement( "fax" );
    params.addElement( "216-412-1235" );
    params.addElement( "payby" );
    params.addElement( "BILL" );
    params.addElement( "invoicing_list" );
    params.addElement( "test@test.example.com" );
    params.addElement( "pkgpart" );
    params.addElement( "101" );
    params.addElement( "popnum" );
    params.addElement( "4018" );
    params.addElement( "username" );
    params.addElement( "testy" );
    params.addElement( "_password" );
    params.addElement( "tester" );
    HashMap result = client.execute( "new_customer", params );

    String error = (String) result.get("error");

    if (error.length() < 1) {

      // successful signup

      String custnum = (String) result.get("custnum");

      logger.trace("[new_customer] signup with custnum "+custnum);

    }else{

      // unsuccessful signup

      logger.warn("[new_customer] signup error: "+error);

      // display error message to user

    }
  }
}