diff --git a/APIFolder/api.htm b/APIFolder/api.htm index 9ed6c0be6..f007036f1 100644 --- a/APIFolder/api.htm +++ b/APIFolder/api.htm @@ -46,17 +46,6 @@ -
-

Customers

- -
@@ -310,27 +299,25 @@ error is parameter-specific. You can use this to display a message near -   -
-
-

Additional Fields

-

+  +

+
+

Additional Fields

+

In Mifos X, any number of "Sets" of "Additional Fields" can be configured for a Mifos X database table ("Type"). -

-

For example, portfolio_client is the database table that holds client data. Typically, MFI's want more client related fields than is provided by Mifos X out-of-the-box. +

+

For example, portfolio_client is the database table that holds client data. Typically, MFI's want more client related fields than is provided by Mifos X out-of-the-box. The MFI might add a Set called "Additional Info" containing some fields that are typically input when creating a client. They might then add another Set called "Highly Improbable Info" containing some fields that are only input in exceptional circumstances. -

-

+

+

The additional fields resource allows you to retrieve and update any Additional Fields data that has been configured in Mifos X. -

-

+

+

The Mifos X Individual Lending client application uses a JQuery plugin called stretchydata which, itself, uses this additional fields resource to provide a pretty flexible additional fields User Interface (UI). Put a link to an example here. -

- - -
-
+

+
+
  @@ -375,59 +362,118 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st +  +
+
+

Retrieve Additional Fields

+

+Returns the Set of Additional Fields data for the ID provided. The ID is the id field of the Type table e.g. portfolio_client might have an id value of 4. The output is a JSON formatted "Generic Resultset". The Generic Resultset contains Column Heading as well as Data information. The Column Heading information may include allowed values (columnValues array). +

+
Arguments
+ None +

Example Request: + http://localhost:8080/mifosng-provider/api/v1/additionalfields/portfolio_client/Additional Information/2 +

+
- -   -
-
-

Retrieve Additional Data

-

- Runs a report and returns the report output. -

-
Arguments
-
-
R_'parameter names' ...
-
optional, No defaults
-
The number and names of the parameters depend on the specific report and how it has been configured. R_officeId is an example parameter name.
-
Note: the prefix R_ stands for Reporting
-
parameterType
-
optional, The only valid value is 'true'. If any other value is provided the argument will be ignored
-
Determines whether the request looks in the list of reports or the list of parameters for its data.
-
exportCSV
-
optional, The only valid value is 'true'. If any other value is provided the argument will be ignored
-
Output will be delivered as a CSV file instead of JSON. Doesn't apply to Pentaho reports.
-
- -

Example Request: - http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1 -

- -
- -
- GET https://thedomainname/v1/reports/{REPORTNAME} - { +
+ GET https://thedomainname/v1/additionalfields/{TYPE}/{SET}/{ID} + { "columnHeaders": [ { - "columnName": "Office/Branch", - "columnType": "VARCHAR", - "columnLength": null, + "columnName": "Ethnic Group", + "columnType": "String", + "columnLength": 50, + "columnDisplayType": "List", + "columnValues": [ + "Bedouin", + "Berber", + "Italian", + "Miknasa", + "Mrazig", + "Other", + "Unknown" + ] + }, + { + "columnName": "Ethnic Group Other", + "columnType": "String", + "columnLength": 50, "columnDisplayType": null, "columnValues": [] }, { - "columnName": "Name", - "columnType": "VARCHAR", - "columnLength": null, + "columnName": "Household Location", + "columnType": "String", + "columnLength": 50, + "columnDisplayType": "List", + "columnValues": [ + "East Sikkim", + "North Sikkim", + "South Sikkim", + "West Sikkim", + "Other" + ] + }, + { + "columnName": "Household Location Other", + "columnType": "String", + "columnLength": 50, "columnDisplayType": null, "columnValues": [] }, { - "columnName": "Joining Date", - "columnType": "DATE", - "columnLength": null, + "columnName": "Religion", + "columnType": "String", + "columnLength": 50, + "columnDisplayType": "List", + "columnValues": [ + "Protestant", + "Catholic", + "Muslim", + "Animist", + "Atheist", + "Other", + "Unknown" + ] + }, + { + "columnName": "Religion Other", + "columnType": "String", + "columnLength": 50, + "columnDisplayType": null, + "columnValues": [] + }, + { + "columnName": "Knowledge of Person", + "columnType": "String", + "columnLength": 50, + "columnDisplayType": "List", + "columnValues": [ + "Staff member", + "Spouse of staff member", + "Son/daughter of staff member", + "Friend of staff member", + "Not known by any staff member", + "Other" + ] + }, + { + "columnName": "Gender", + "columnType": "String", + "columnLength": 10, + "columnDisplayType": "List", + "columnValues": [ + "Female", + "Male" + ] + }, + { + "columnName": "Whois", + "columnType": "Text", + "columnLength": 0, "columnDisplayType": null, "columnValues": [] } @@ -435,115 +481,67 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st "data": [ { "row": [ - "Demo MFI Head Office", - "O'Meara, Patrick", - "2009-01-04" + "Berber", + null, + "East Sikkim", + null, + "Animist", + "jjjjjjj", + "Son/daughter of staff member", + "Female", + "its\r\nme of\r\ncourse\r\nyes\r\nend and the end of it all" ] - }, - { - "row": [ - "Demo MFI Head Office", - "O'Meara, Dennis", - "2009-01-04" - ] - }, - { - "row": [ - "Demo MFI Head Office", - "Smith, John", - "2009-01-11" - ] - }, -... more "row" entries - ] -} -
-
- - -   -
-
-

Update Additional Data

-

- Runs a report and returns the report output. -

-
Arguments
-
-
R_'parameter names' ...
-
optional, No defaults
-
The number and names of the parameters depend on the specific report and how it has been configured. R_officeId is an example parameter name.
-
Note: the prefix R_ stands for Reporting
-
parameterType
-
optional, The only valid value is 'true'. If any other value is provided the argument will be ignored
-
Determines whether the request looks in the list of reports or the list of parameters for its data.
-
exportCSV
-
optional, The only valid value is 'true'. If any other value is provided the argument will be ignored
-
Output will be delivered as a CSV file instead of JSON. Doesn't apply to Pentaho reports.
-
- -

Example Request: - http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1 -

- -
- -
- GET https://thedomainname/v1/reports/{REPORTNAME} - { - "columnHeaders": [ - { - "columnName": "Office/Branch", - "columnType": "VARCHAR", - "columnLength": null, - "columnDisplayType": null, - "columnValues": [] - }, - { - "columnName": "Name", - "columnType": "VARCHAR", - "columnLength": null, - "columnDisplayType": null, - "columnValues": [] - }, - { - "columnName": "Joining Date", - "columnType": "DATE", - "columnLength": null, - "columnDisplayType": null, - "columnValues": [] } - ], - "data": [ - { - "row": [ - "Demo MFI Head Office", - "O'Meara, Patrick", - "2009-01-04" - ] - }, - { - "row": [ - "Demo MFI Head Office", - "O'Meara, Dennis", - "2009-01-04" - ] - }, - { - "row": [ - "Demo MFI Head Office", - "Smith, John", - "2009-01-11" - ] - }, -... more "row" entries ] -} -
+} +
+
+  +
+
+

Update Additional Fields

+

+Updates the Set of Additional Fields data for the ID provided. The ID is the id field of the Type table e.g. portfolio_client might have an id value of 4. +

+

+JPW note: currently using ed_transType = "E" for edit and ed_transType = "A" for new... probably need to not do that. +

+
Arguments
+ None + +
+ +
+ POST https://thedomainname/v1/additionalfields/{TYPE}/{SET}/{ID} + http://localhost:8080/mifosng-provider/api/v1/additionalfields/portfolio_client/Additional Information/2 + +Request Body: +Content-Type: application/json +{ +"ed_transType":"E", +"Ethnic_Group":"Berber", +"Ethnic_Group_Other":"", +"Household_Location":"East Sikkim", +"Household_Location_Other":"", +"Religion":"Animist", +"Religion_Other":"jjjjjjj", +"Knowledge_of_Person":"Son/daughter of staff member", +"Gender":"Female", +"Whois":"its\r\nme of\r\ncourse\r\nyes\r\nend and the end of it all" +} + + { + "entityId": 2 +} + + +
+
+ @@ -572,7 +570,7 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st -   + 

List Reports

@@ -664,10 +662,7 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st - - - -   + 

Running a Report

@@ -752,1671 +747,6 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st - - - - - -   -
-
-

Creating a New Customer

-

- Creates a new customer object. -

- -
Arguments
-
-
card
-
optional, default is null
-
- A card to attach to the customer. The card can either be a token, - like the ones returned by our - Stripe.js, - or a dictionary containing a - user's credit card details, with the options described - below. Whenever you attach a card to a customer, Stripe will automatically validate the - card. A customer with a card can be used when creating a charge or put on a recurring - billing plan. - -
-
number
-
required
-
The card number, as a string without any separators.
- -
exp_month
-
required
-
Two digit number representing the card's expiration month.
- -
exp_year
-
required
-
Four digit number representing the card's expiration year.
- -
cvc
-
optional, highly recommended
-
Card security code
- -
name
-
optional
-
Cardholder's full name.
- -
address_line1
-
optional
- -
address_line2
-
optional
- -
address_zip
-
optional
- -
address_state
-
optional
- -
address_country
-
optional
-
-
- -
coupon
-
optional, default is null
-
- If you provide a coupon code, the customer will have a - discount applied on all recurring charges. Charges - you create through the API will not have the discount. - You can manage your coupons in the - coupon section of your - account. -
- -
email
-
optional, default is null
-
- The customer's email address. It is displayed alongside - the customer in the web interface and can be useful for searching and tracking. -
- -
description
-
optional, default is null
-
- An arbitrary string which you can attach to a customer - object. It is displayed alongside the customer in the - web interface. -
- -
plan
-
optional, default is null
-
- The identifier of the plan to subscribe the customer - to. If provided, the returned customer object has a - 'subscription' attribute describing the state of the - customer's subscription. -
- -
trial_end
-
optional, default is null
-
- UTC integer timestamp representing the end of the trial period - the customer will get before being charged for the first time. - If set, trial_end will override the default trial period of the - plan the customer is being subscribed to. -
-
- -
Returns
-

- Returns a customer object if the call succeeded. The - returned object will have information about - subscriptions, discount, and cards, if that information - has been provided. If a non-free plan is specified and - a card is not provided (unless the plan has a trial period), the call will return an error. - If a non-existent plan or a non-existent or expired - coupon is provided, the call will return an error. -

-

- If a card has been attached to the customer, the - returned customer object will have an active_card - attribute containing the card's details. -

- -
- -
- POST https://api.stripe.com/v1/customers - - curl https://api.stripe.com/v1/customers \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -d "description=Customer for site@stripe.com" \ - -d "card[number]=4242424242424242" \ - -d "card[exp_month]=5" \ - -d "card[exp_year]=2013" - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "You must supply a valid card" - } -} - -
-
- -   -
-
-

Retrieving a Customer

-

- Retrieves the details of an existing customer. You need - only supply the unique customer identifier that was - returned upon customer creation. -

- -

- Like with a charge, you can view the retrieved customer - directly in your browser. -

- -

- https://vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE@api.stripe.com/v1/customers/ch_I7HoyUbJDACuPe -

- -
Arguments
-
-
id
-
required
-
- The identifier of the customer to be retrieved. -
-
- -
Returns
-

- Returns a customer object if a valid identifier was provided. - When requesting the ID of a customer that has been deleted, - a subset of the customer's information will be returned, - including a "deleted" property, which will be true. -

-
- -
- GET https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

Updating a Customer

-

- Updates the specified customer by setting the values of - the parameters passed. Any parameters not provided will - be left unchanged. For example, if you pass - the card parameter, that becomes the - customer's active card which will be used for all - charges in future. -

- -

- This request accepts mostly the same arguments as the - customer creation call. However, subscription-related - arguments (plan and - trial_end) are not accepted. To - change those, one must - update the customer's subscription directly. -

- -
Arguments
-

-

-
card
-
optional, default is null
-
- A new card to attach to the customer. The card can either be a token, - like the ones returned by our - Stripe.js, - or a dictionary containing a - user's credit card details, with the options described - below. A customer with a card can be used when - creating a charge or put on a recurring billing - plan. Although not all information is required, the - extra info helps prevent fraud. - -
-
number
-
required
-
The card number, as a string without any separators.
- -
exp_month
-
required
-
Two digit number representing the card's expiration month.
- -
exp_year
-
required
-
Four digit number representing the card's expiration year.
- -
cvc
-
optional, highly recommended
-
Card security code
- -
name
-
optional
-
Cardholder's full name.
- -
address_line1
-
optional
- -
address_line2
-
optional
- -
address_zip
-
optional
- -
address_state
-
optional
- -
address_country
-
optional
-
-
- -
coupon
-
optional, default is null
-
- If you provide a coupon code, the customer will have a - discount applied on all recurring charges. Charges - you create through the API will not have the discount. - You can manage your coupons in the - coupon section of your - account. -
- -
description
-
optional, default is null
-
- An arbitrary string which you can attach to a customer - object. It is displayed alongside the charge in the - web interface. It's often a good idea to use an - email address as a description for tracking later. -
- -
email
-
optional
-
- The customer's email address. It is displayed alongside - the customer in the web interface and can be useful for searching and tracking. -
-

- -
Returns
-

- Returns the customer object if the update succeeded. - Errors will be thrown if update parameters are invalid. - For example, specifying an invalid coupon or - an invalid card will return an error. -

-
- -
- POST https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -d "description=Customer for site@stripe.com" - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": "Customer for site@stripe.com", - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

Deleting a Customer

- -

Permanently deletes a customer. It cannot be undone.

- -
Arguments
-
-
id
-
required
-
- The identifier of the customer to be deleted. -
-
- -
Returns
-

- Returns an object with a deleted parameter on success. - If the customer ID does not exist, an error is returned. -

-

- Unlike other objects, deleted customers can still be - retrieved through the API, in order to be able to track - the history of customers while still removing their - credit card details and preventing any further operations - to be performed (such as adding a new subscription). -

-
- -
- DELETE https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -X DELETE - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

List all Customers

-

- Returns a list of your customers. The customers are - returned sorted by creation date, with the most recently - created customers appearing first. -

- -

- Like with an individual customer, you can view the list - of customers directly in your browser. -

- -

- https://vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE@api.stripe.com/v1/customers -

- -
Arguments
-
-
count
-
optional, default is 10
-
- A limit on the number of customers to be returned. - Count can range between 1 and 100 customers. -
- -
offset
-
optional, default is 0
-
- An offset into your customer array. The API will - return the requested number of customers starting at - that offset. -
-
- -
Returns
-

- A dictionary with a data - property that contains an array of up to count customers, - starting at index offset. Each entry - in the array is a separate customer object. If no more - customers are available, the resulting array will be - empty. This request should never return an error. -

-
- -
- GET https://api.stripe.com/v1/customers - - curl https://api.stripe.com/v1/customers \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: - - - { - data: [ - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 - }, - {...}, - {...} - ] -} - -
-
- - - - - - - - - - - - - - -   -
-
-

Customers

-

- Customer objects allow you to perform recurring charges - and track multiple charges that are associated with the - same customer. The API allows you to create, delete, - and update your customers. You can retrieve individual - customers as well as a list of all your customers. -

-
-
- -   -
-
-

The customer object

-
Attributes
-
- -
- id -
-
- - - string - - - -
- - -
- object -
-
- - string, value is "customer" - - -
- - -
- livemode -
-
- - - boolean - - - -
- - -
- created -
-
- - - timestamp - - - -
- - -
- account_balance -
-
- - - integer - - - or null -
- -
Current balance, if any, being stored on the customer's -account. If negative, the customer has credit to apply - to the next invoice. If positive, the customer has an amount -owed that will be added to the next invoice. The balance does not - refer to any unpaid invoices; it solely takes into account -amounts that have yet to be successfully applied to any invoice.
- - -
- active_card -
-
- - -
hash
-
- Hash describing the current card on the customer, if there is one. -
- -
- object -
-
- - - string - - - -
- - -
- exp_month -
-
- - - integer - - - -
- - -
- exp_year -
-
- - - integer - - - -
- - -
- fingerprint -
-
- - - string - - - -
- -
Uniquely identifies this particular card number. You can use this - attribute to check whether two customers who've signed up with you are using the same card - number, for example.
- - -
- last4 -
-
- - - string - - - -
- - -
- type -
-
- - - string - - - -
- -
Card brand. Can be Visa, American Express, MasterCard, Discover, JCB, Diners Club, or Unknown
- - -
- address_country -
-
- - - string - - - or null -
- -
Billing address country, if provided when creating card
- - -
- address_line1 -
-
- - - string - - - or null -
- - -
- address_line1_check -
-
- - - string - - - or null -
- -
If address_line1 was provided, results of the check: pass, fail, or unchecked
- - -
- address_line2 -
-
- - - string - - - or null -
- - -
- address_state -
-
- - - string - - - or null -
- - -
- address_zip -
-
- - - string - - - or null -
- - -
- address_zip_check -
-
- - - string - - - or null -
- -
If address_zip was provided, results of the check: pass, fail, or unchecked
- - -
- country -
-
- - - string - - - or null -
- -
Two-letter ISO code representing the country of the card (as accurately as we can determine it). - You could use this attribute to get a sense of the international breakdown of cards you've collected.
- - -
- cvc_check -
-
- - - string - - - or null -
- -
If a CVC was provided, results of the check: pass, fail, or unchecked
- - -
- name -
-
- - - string - - - or null -
- -
Cardholder name
- - -
- - - - - or null -
- - -
- delinquent -
-
- - - boolean - - - or null -
- -
Whether or not the latest charge for the customer's latest invoice has failed
- - -
- description -
-
- - - string - - - or null -
- - -
- discount -
-
- - - hash, discount object - - - or null -
- -
Describes the current discount active on the customer, if there is one.
- - -
- email -
-
- - - string - - - or null -
- - -
- subscription -
-
- - - hash, subscription object - - - or null -
- -
Hash describing the current subscription on the customer, if there is one. If the customer has no current subscription, - this will be null.
- - -
- - -
-
- { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} -
-
- -   -
-
-

Creating a New Customer

-

- Creates a new customer object. -

- -
Arguments
-
-
card
-
optional, default is null
-
- A card to attach to the customer. The card can either be a token, - like the ones returned by our - Stripe.js, - or a dictionary containing a - user's credit card details, with the options described - below. Whenever you attach a card to a customer, Stripe will automatically validate the - card. A customer with a card can be used when creating a charge or put on a recurring - billing plan. - -
-
number
-
required
-
The card number, as a string without any separators.
- -
exp_month
-
required
-
Two digit number representing the card's expiration month.
- -
exp_year
-
required
-
Four digit number representing the card's expiration year.
- -
cvc
-
optional, highly recommended
-
Card security code
- -
name
-
optional
-
Cardholder's full name.
- -
address_line1
-
optional
- -
address_line2
-
optional
- -
address_zip
-
optional
- -
address_state
-
optional
- -
address_country
-
optional
-
-
- -
coupon
-
optional, default is null
-
- If you provide a coupon code, the customer will have a - discount applied on all recurring charges. Charges - you create through the API will not have the discount. - You can manage your coupons in the - coupon section of your - account. -
- -
email
-
optional, default is null
-
- The customer's email address. It is displayed alongside - the customer in the web interface and can be useful for searching and tracking. -
- -
description
-
optional, default is null
-
- An arbitrary string which you can attach to a customer - object. It is displayed alongside the customer in the - web interface. -
- -
plan
-
optional, default is null
-
- The identifier of the plan to subscribe the customer - to. If provided, the returned customer object has a - 'subscription' attribute describing the state of the - customer's subscription. -
- -
trial_end
-
optional, default is null
-
- UTC integer timestamp representing the end of the trial period - the customer will get before being charged for the first time. - If set, trial_end will override the default trial period of the - plan the customer is being subscribed to. -
-
- -
Returns
-

- Returns a customer object if the call succeeded. The - returned object will have information about - subscriptions, discount, and cards, if that information - has been provided. If a non-free plan is specified and - a card is not provided (unless the plan has a trial period), the call will return an error. - If a non-existent plan or a non-existent or expired - coupon is provided, the call will return an error. -

-

- If a card has been attached to the customer, the - returned customer object will have an active_card - attribute containing the card's details. -

- -
- -
- POST https://api.stripe.com/v1/customers - - curl https://api.stripe.com/v1/customers \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -d "description=Customer for site@stripe.com" \ - -d "card[number]=4242424242424242" \ - -d "card[exp_month]=5" \ - -d "card[exp_year]=2013" - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "You must supply a valid card" - } -} - -
-
- -   -
-
-

Retrieving a Customer

-

- Retrieves the details of an existing customer. You need - only supply the unique customer identifier that was - returned upon customer creation. -

- -

- Like with a charge, you can view the retrieved customer - directly in your browser. -

- -

- https://vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE@api.stripe.com/v1/customers/ch_I7HoyUbJDACuPe -

- -
Arguments
-
-
id
-
required
-
- The identifier of the customer to be retrieved. -
-
- -
Returns
-

- Returns a customer object if a valid identifier was provided. - When requesting the ID of a customer that has been deleted, - a subset of the customer's information will be returned, - including a "deleted" property, which will be true. -

-
- -
- GET https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

Updating a Customer

-

- Updates the specified customer by setting the values of - the parameters passed. Any parameters not provided will - be left unchanged. For example, if you pass - the card parameter, that becomes the - customer's active card which will be used for all - charges in future. -

- -

- This request accepts mostly the same arguments as the - customer creation call. However, subscription-related - arguments (plan and - trial_end) are not accepted. To - change those, one must - update the customer's subscription directly. -

- -
Arguments
-

-

-
card
-
optional, default is null
-
- A new card to attach to the customer. The card can either be a token, - like the ones returned by our - Stripe.js, - or a dictionary containing a - user's credit card details, with the options described - below. A customer with a card can be used when - creating a charge or put on a recurring billing - plan. Although not all information is required, the - extra info helps prevent fraud. - -
-
number
-
required
-
The card number, as a string without any separators.
- -
exp_month
-
required
-
Two digit number representing the card's expiration month.
- -
exp_year
-
required
-
Four digit number representing the card's expiration year.
- -
cvc
-
optional, highly recommended
-
Card security code
- -
name
-
optional
-
Cardholder's full name.
- -
address_line1
-
optional
- -
address_line2
-
optional
- -
address_zip
-
optional
- -
address_state
-
optional
- -
address_country
-
optional
-
-
- -
coupon
-
optional, default is null
-
- If you provide a coupon code, the customer will have a - discount applied on all recurring charges. Charges - you create through the API will not have the discount. - You can manage your coupons in the - coupon section of your - account. -
- -
description
-
optional, default is null
-
- An arbitrary string which you can attach to a customer - object. It is displayed alongside the charge in the - web interface. It's often a good idea to use an - email address as a description for tracking later. -
- -
email
-
optional
-
- The customer's email address. It is displayed alongside - the customer in the web interface and can be useful for searching and tracking. -
-

- -
Returns
-

- Returns the customer object if the update succeeded. - Errors will be thrown if update parameters are invalid. - For example, specifying an invalid coupon or - an invalid card will return an error. -

-
- -
- POST https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -d "description=Customer for site@stripe.com" - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": "Customer for site@stripe.com", - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

Deleting a Customer

- -

Permanently deletes a customer. It cannot be undone.

- -
Arguments
-
-
id
-
required
-
- The identifier of the customer to be deleted. -
-
- -
Returns
-

- Returns an object with a deleted parameter on success. - If the customer ID does not exist, an error is returned. -

-

- Unlike other objects, deleted customers can still be - retrieved through the API, in order to be able to track - the history of customers while still removing their - credit card details and preventing any further operations - to be performed (such as adding a new subscription). -

-
- -
- DELETE https://api.stripe.com/v1/customers/{CUSTOMER_ID} - - curl https://api.stripe.com/v1/customers/cus_QEvO1l6xtJNbTI \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ - -X DELETE - - - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 -} - - { - "error": { - "type": "invalid_request_error", - "message": "No such customer: cus_QEvO1l6xtJNbTI" - } -} - -
-
- -   -
-
-

List all Customers

-

- Returns a list of your customers. The customers are - returned sorted by creation date, with the most recently - created customers appearing first. -

- -

- Like with an individual customer, you can view the list - of customers directly in your browser. -

- -

- https://vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE@api.stripe.com/v1/customers -

- -
Arguments
-
-
count
-
optional, default is 10
-
- A limit on the number of customers to be returned. - Count can range between 1 and 100 customers. -
- -
offset
-
optional, default is 0
-
- An offset into your customer array. The API will - return the requested number of customers starting at - that offset. -
-
- -
Returns
-

- A dictionary with a data - property that contains an array of up to count customers, - starting at index offset. Each entry - in the array is a separate customer object. If no more - customers are available, the resulting array will be - empty. This request should never return an error. -

-
- -
- GET https://api.stripe.com/v1/customers - - curl https://api.stripe.com/v1/customers \ - -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: - - - { - data: [ - { - "discount": { - "end": 1339507966, - "start": 1336829566, - "object": "discount", - "customer": "cus_QEvO1l6xtJNbTI", - "id": "di_Ogh2mPRH0Y200d", - "coupon": { - "times_redeemed": 1, - "duration_in_months": null, - "livemode": false, - "redeem_by": null, - "object": "coupon", - "duration": "once", - "percent_off": 10, - "id": "JAVA-COUPON-fa8e8918-2f9e-4def-9675-ed19d6f4d41b", - "max_redemptions": null - } - }, - "livemode": false, - "delinquent": false, - "object": "customer", - "email": null, - "subscription": null, - "account_balance": 0, - "description": null, - "id": "cus_QEvO1l6xtJNbTI", - "active_card": null, - "created": 1336829566 - }, - {...}, - {...} - ] -} - -
-
- - - - - - - -
diff --git a/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSets.java b/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSets.java deleted file mode 100644 index 843a6baa5..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSets.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.mifosng.data; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class AdditionalFieldSets { - - private List additionalFieldsSets = new ArrayList(); - - protected AdditionalFieldSets() { - // - } - - public AdditionalFieldSets(final List additionalFieldsSets) { - this.additionalFieldsSets = additionalFieldsSets; - } - - public List getAdditionalFieldsSets() { - return additionalFieldsSets; - } - - public void setAdditionalFieldsSets(List additionalFieldsSets) { - this.additionalFieldsSets = additionalFieldsSets; - } - -} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSet.java b/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSet.java similarity index 77% rename from mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSet.java rename to mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSet.java index 2f9890ca7..9ac3cd38d 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldSet.java +++ b/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSet.java @@ -3,16 +3,16 @@ package org.mifosng.data; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class AdditionalFieldSet { +public class AdditionalFieldsSet { private Integer id; private String name; private String type; - protected AdditionalFieldSet() { + protected AdditionalFieldsSet() { // } - public AdditionalFieldSet(final Integer id, final String name, final String type) { + public AdditionalFieldsSet(final Integer id, final String name, final String type) { this.id = id; this.name = name; this.type = type; diff --git a/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSets.java b/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSets.java new file mode 100644 index 000000000..7eadb8816 --- /dev/null +++ b/mifosng-data/src/main/java/org/mifosng/data/AdditionalFieldsSets.java @@ -0,0 +1,29 @@ +package org.mifosng.data; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class AdditionalFieldsSets { + + private List additionalFieldsSets = new ArrayList(); + + protected AdditionalFieldsSets() { + // + } + + public AdditionalFieldsSets(final List additionalFieldsSets) { + this.additionalFieldsSets = additionalFieldsSets; + } + + public List getAdditionalFieldsSets() { + return additionalFieldsSets; + } + + public void setAdditionalFieldsSets(List additionalFieldsSets) { + this.additionalFieldsSets = additionalFieldsSets; + } + +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingService.java b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingService.java index d694b59ef..98c84964d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingService.java @@ -4,7 +4,7 @@ import java.util.Map; import javax.ws.rs.core.StreamingOutput; -import org.mifosng.data.AdditionalFieldSets; +import org.mifosng.data.AdditionalFieldsSets; import org.mifosng.data.reports.GenericResultset; public interface ReadExtraDataAndReportingService { @@ -13,14 +13,13 @@ public interface ReadExtraDataAndReportingService { Map extractedQueryParams); // @PreAuthorize(value = "hasAnyRole('REPORTING_SUPER_USER_ROLE')") - GenericResultset retrieveGenericResultset(String name, - String type, Map extractedQueryParams); + GenericResultset retrieveGenericResultset(String name, String type, + Map extractedQueryParams); - AdditionalFieldSets retrieveExtraDatasetNames(String datasetType); + AdditionalFieldsSets retrieveExtraDatasetNames(String type); - GenericResultset retrieveExtraData(String datasetType, String datasetName, - String datasetPKValue); + GenericResultset retrieveExtraData(String type, String set, String id); - void tempSaveExtraData(String datasetType, String datasetName, - String datasetPKValue, Map queryParams); + void updateExtraData(String type, String set, String id, + Map queryParams); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java index c0868b440..5d64e884b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java @@ -20,8 +20,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; -import org.mifosng.data.AdditionalFieldSet; -import org.mifosng.data.AdditionalFieldSets; +import org.mifosng.data.AdditionalFieldsSet; +import org.mifosng.data.AdditionalFieldsSets; import org.mifosng.data.reports.GenericResultset; import org.mifosng.data.reports.ResultsetColumnHeader; import org.mifosng.data.reports.ResultsetDataRow; @@ -159,12 +159,12 @@ public class ReadExtraDataAndReportingServiceImpl implements String sql; if (name.equals(".")) { - sql = "select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category," + - " rp.parameter_id, rp.report_parameter_name, p.parameter_name" + - " from stretchy_report r" + - " left join stretchy_report_parameter rp on rp.report_id = r.report_id" + - " left join stretchy_parameter p on p.parameter_id = rp.parameter_id" + - " order by r.report_name, rp.parameter_id"; + sql = "select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category," + + " rp.parameter_id, rp.report_parameter_name, p.parameter_name" + + " from stretchy_report r" + + " left join stretchy_report_parameter rp on rp.report_id = r.report_id" + + " left join stretchy_parameter p on p.parameter_id = rp.parameter_id" + + " order by r.report_name, rp.parameter_id"; } else { try { sql = getSQLtoRun(name, type, queryParams); @@ -237,8 +237,7 @@ public class ReadExtraDataAndReportingServiceImpl implements } private String getSQLtoRun(final String name, final String type, - final Map queryParams) - throws SQLException { + final Map queryParams) throws SQLException { String sql = null; String rptDB = queryParams.get("${rptDB}"); if ((rptDB == null) || rptDB.equals("")) { @@ -334,9 +333,9 @@ public class ReadExtraDataAndReportingServiceImpl implements } @Override - public AdditionalFieldSets retrieveExtraDatasetNames(String type) { + public AdditionalFieldsSets retrieveExtraDatasetNames(String type) { - List additionalFieldsSets = new ArrayList(); + List additionalFieldsSets = new ArrayList(); Connection db_connection; try { db_connection = dataSource.getConnection(); @@ -348,16 +347,15 @@ public class ReadExtraDataAndReportingServiceImpl implements } else { whereClause = "where t.`name` = '" + type + "'"; } - String sql = "select d.id, d.`name` as datasetName, t.`name` as datasetType from stretchydata_dataset d join stretchydata_datasettype t on t.id = d.datasettype_id " + String sql = "select d.id, d.`name` as 'set', t.`name` as 'type' from stretchydata_dataset d join stretchydata_datasettype t on t.id = d.datasettype_id " + whereClause + " order by d.`name`"; ResultSet rs = db_statement.executeQuery(sql); while (rs.next()) { - additionalFieldsSets - .add(new AdditionalFieldSet(rs.getInt("id"), rs - .getString("datasetName"), rs - .getString("datasetType"))); + additionalFieldsSets.add(new AdditionalFieldsSet(rs + .getInt("id"), rs.getString("set"), rs + .getString("type"))); } db_statement.close(); @@ -370,37 +368,35 @@ public class ReadExtraDataAndReportingServiceImpl implements .status(Status.BAD_REQUEST).entity(e.getMessage()).build()); } - return new AdditionalFieldSets(additionalFieldsSets); + return new AdditionalFieldsSets(additionalFieldsSets); } @Override - public GenericResultset retrieveExtraData(String datasetType, - String datasetName, String datasetPKValue) { + public GenericResultset retrieveExtraData(String type, String set, String id) { - if (datasetType == null) { - logger.info("Extra Data Table Type not Found"); + if (type == null) { + logger.info("Type not Found"); return null; } - if (datasetName == null) { - logger.info("Extra Data Table Name not Found"); + if (set == null) { + logger.info("Set not Found"); return null; } - if (datasetPKValue == null) { - logger.info("Extra Data Table ID not Found"); + if (id == null) { + logger.info("Id not Found"); return null; } long startTime = System.currentTimeMillis(); - logger.info("STARTING EXTRA DATA TABLE: " + datasetName + " ID: " - + datasetPKValue); + logger.info("STARTING SET: " + set + " ID: " + id); try { - GenericResultset result = fillExtraDataGenericResultSet( - datasetType, datasetName, datasetPKValue); + GenericResultset result = fillExtraDataGenericResultSet(type, set, + id); long elapsed = System.currentTimeMillis() - startTime; - logger.info("FINISHING EXTRA DATA TABLE: " + datasetName - + " Elapsed Time: " + elapsed); + logger.info("FINISHING SET: " + set + " Elapsed Time: " + + elapsed); return result; } catch (SQLException e) { logger.info("Error - SQL: " + e.toString()); @@ -408,22 +404,18 @@ public class ReadExtraDataAndReportingServiceImpl implements } } - private GenericResultset fillExtraDataGenericResultSet(String datasetType, - String datasetName, String datasetPKValue) throws SQLException { + private GenericResultset fillExtraDataGenericResultSet(String type, + String set, String id) throws SQLException { GenericResultset result = new GenericResultset(); - String fullDatasetName = getFullDatasetName(datasetType, datasetName); + String fullDatasetName = getFullDatasetName(type, set); Connection db_connection = dataSource.getConnection(); Statement db_statement1 = db_connection.createStatement(); Statement db_statement2 = db_connection.createStatement(); Statement db_statement3 = db_connection.createStatement(); String sql = "select f.`name`, f.data_type, f.data_length, f.display_type, f.allowed_list_id from stretchydata_datasettype t join stretchydata_dataset d on d.datasettype_id = t.id join stretchydata_dataset_fields f on f.dataset_id = d.id where d.`name` = '" - + datasetName - + "' and t.`name` = '" - + datasetType - + "' order by f.id"; + + set + "' and t.`name` = '" + type + "' order by f.id"; - // logger.info("specific: " + sql); ResultSet rsmd = db_statement1.executeQuery(sql); List columnHeaders = new ArrayList(); @@ -461,7 +453,7 @@ public class ReadExtraDataAndReportingServiceImpl implements result.setColumnHeaders(columnHeaders); sql = "select " + selectFieldList + " from `" + fullDatasetName - + "` where id = " + datasetPKValue; + + "` where id = " + id; ResultSet rs = db_statement3.executeQuery(sql); String columnName = null; @@ -495,9 +487,8 @@ public class ReadExtraDataAndReportingServiceImpl implements } - private String getFullDatasetName(final String datasetType, - final String datasetName) { - return datasetType + "_extra_" + datasetName; + private String getFullDatasetName(final String type, final String set) { + return type + "_extra_" + set; } private static String replace(String str, String pattern, String replace) { @@ -515,11 +506,10 @@ public class ReadExtraDataAndReportingServiceImpl implements } @Override - public void tempSaveExtraData(String datasetType, String datasetName, - String datasetPKValue, Map queryParams) { - logger.info("SaveExtraData - DatasetType: " + datasetType - + " DatasetName: " + datasetName + " datasetPKValue: " - + datasetPKValue); + public void updateExtraData(String type, String set, String id, + Map queryParams) { + logger.info("updateExtraData - type: " + type + " set: " + set + + " id: " + id); logger.info("startjpw: "); Set keys = queryParams.keySet(); @@ -531,9 +521,8 @@ public class ReadExtraDataAndReportingServiceImpl implements logger.info("endjpw: "); - String fullDatasetName = getFullDatasetName(datasetType, datasetName); - String saveSql = getSaveSql(fullDatasetName, datasetPKValue, - queryParams); + String fullDatasetName = getFullDatasetName(type, set); + String saveSql = getSaveSql(fullDatasetName, id, queryParams); try { Connection db_connection = dataSource.getConnection(); Statement db_statement = db_connection.createStatement(); @@ -550,7 +539,7 @@ public class ReadExtraDataAndReportingServiceImpl implements } - private String getSaveSql(String fullDatasetName, String datasetPKValue, + private String getSaveSql(String fullSetName, String id, Map queryParams) { String errMsg = ""; @@ -572,7 +561,7 @@ public class ReadExtraDataAndReportingServiceImpl implements if (transType.equals("E")) { boolean firstColumn = true; - saveSql = "update `" + fullDatasetName + "` "; + saveSql = "update `" + fullSetName + "` "; for (String key : keys) { if (!(key.equals("ed_transType") || key.equals("id"))) { @@ -596,7 +585,7 @@ public class ReadExtraDataAndReportingServiceImpl implements } } - saveSql += " where id = " + datasetPKValue; + saveSql += " where id = " + id; } else { String insertColumns = ""; String selectColumns = ""; @@ -619,9 +608,8 @@ public class ReadExtraDataAndReportingServiceImpl implements } } - saveSql = "insert into `" + fullDatasetName + "` (id" - + insertColumns + ")" + " select " + datasetPKValue - + " as id" + selectColumns; + saveSql = "insert into `" + fullSetName + "` (id" + insertColumns + + ")" + " select " + id + " as id" + selectColumns; } // logger.info("Save SQL: " + saveSql); return saveSql; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/AdditionalFieldsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/AdditionalFieldsApiResource.java index 04dd263d0..11dc5783d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/AdditionalFieldsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/AdditionalFieldsApiResource.java @@ -22,10 +22,10 @@ import javax.ws.rs.core.UriInfo; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import org.mifosng.data.AdditionalFieldsSets; import org.mifosng.data.EntityIdentifier; import org.mifosng.data.ErrorResponse; import org.mifosng.data.ErrorResponseList; -import org.mifosng.data.AdditionalFieldSets; import org.mifosng.data.reports.GenericResultset; import org.mifosng.platform.InvalidSqlException; import org.mifosng.platform.ReadExtraDataAndReportingService; @@ -34,42 +34,50 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; + @Path("/v1/additionalfields") @Component @Scope("singleton") public class AdditionalFieldsApiResource { - private final static Logger logger = LoggerFactory.getLogger(AdditionalFieldsApiResource.class); - + private final static Logger logger = LoggerFactory + .getLogger(AdditionalFieldsApiResource.class); + @Autowired private ReadExtraDataAndReportingService readExtraDataAndReportingService; @GET @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) - @Produces({ MediaType.APPLICATION_JSON}) + @Produces({ MediaType.APPLICATION_JSON }) public Response datasets(@Context UriInfo uriInfo) { - - MultivaluedMap queryParams = uriInfo.getQueryParameters(); - String type = queryParams.getFirst("type"); - AdditionalFieldSets result = this.readExtraDataAndReportingService.retrieveExtraDatasetNames(type); + MultivaluedMap queryParams = uriInfo + .getQueryParameters(); + String type = queryParams.getFirst("type"); + + AdditionalFieldsSets result = this.readExtraDataAndReportingService + .retrieveExtraDatasetNames(type); return Response.ok().entity(result).build(); } - + @GET - @Path("{datasetType}/{datasetName}/{datasetPKValue}") + @Path("{type}/{set}/{id}") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) - @Produces({ MediaType.APPLICATION_JSON}) - public Response extraData(@PathParam("datasetType") final String datasetType,@PathParam("datasetName") final String datasetName, @PathParam("datasetPKValue") final String datasetPKValue, @Context UriInfo uriInfo) { - + @Produces({ MediaType.APPLICATION_JSON }) + public Response extraData(@PathParam("type") final String type, + @PathParam("set") final String set, + @PathParam("id") final String id, @Context UriInfo uriInfo) { + try { - GenericResultset result = this.readExtraDataAndReportingService.retrieveExtraData(datasetType, datasetName, datasetPKValue); - + GenericResultset result = this.readExtraDataAndReportingService + .retrieveExtraData(type, set, id); + return Response.ok().entity(result).build(); } catch (InvalidSqlException e) { List allErrors = new ArrayList(); - ErrorResponse err = new ErrorResponse("extradata.invalid.sql", "sql", e.getSql()); + ErrorResponse err = new ErrorResponse("extradata.invalid.sql", + "sql", e.getSql()); allErrors.add(err); throw new WebApplicationException(Response @@ -77,18 +85,20 @@ public class AdditionalFieldsApiResource { .entity(new ErrorResponseList(allErrors)).build()); } } - + @POST - @Path("{datasetType}/{datasetName}/{datasetPKValue}") + @Path("{type}/{set}/{id}") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) - @Produces({ MediaType.APPLICATION_JSON}) - public Response saveExtraData(@PathParam("datasetType") final String datasetType,@PathParam("datasetName") final String datasetName, @PathParam("datasetPKValue") final String datasetPKValue, String reqbody) { - - try { + @Produces({ MediaType.APPLICATION_JSON }) + public Response saveExtraData(@PathParam("type") final String type, + @PathParam("set") final String set, + @PathParam("id") final String id, String reqbody) { + + try { Map queryParams = new HashMap(); - String pValue = ""; - String pName; + String pValue = ""; + String pName; try { JSONObject jsonObj = new JSONObject(reqbody); JSONArray jsonArr = jsonObj.names(); @@ -96,7 +106,7 @@ public class AdditionalFieldsApiResource { for (int i = 0; i < jsonArr.length(); i++) { pName = (String) jsonArr.get(i); pValue = jsonObj.getString(pName); - logger.info( pName + " - " + pValue); + logger.info(pName + " - " + pValue); queryParams.put(pName, pValue); } } else { @@ -106,20 +116,22 @@ public class AdditionalFieldsApiResource { } } catch (JSONException e) { throw new WebApplicationException(Response - .status(Status.BAD_REQUEST) - .entity("JSON body is wrong").build()); + .status(Status.BAD_REQUEST) + .entity("JSON body is wrong").build()); } - - - this.readExtraDataAndReportingService.tempSaveExtraData(datasetType, datasetName, datasetPKValue, queryParams); - - EntityIdentifier entityIdentifier = new EntityIdentifier(Long.valueOf(datasetPKValue)); - + + this.readExtraDataAndReportingService.updateExtraData(type, set, + id, queryParams); + + EntityIdentifier entityIdentifier = new EntityIdentifier( + Long.valueOf(id)); + return Response.ok().entity(entityIdentifier).build(); } catch (InvalidSqlException e) { List allErrors = new ArrayList(); - ErrorResponse err = new ErrorResponse("extradata.invalid.sql", "sql", e.getSql()); + ErrorResponse err = new ErrorResponse("extradata.invalid.sql", + "sql", e.getSql()); allErrors.add(err); logger.info("way bad: " + err.toString());