All Downloads are FREE. Search and download functionalities are using the official Maven repository.

models.dsl.examples.propertysets.TaxBlaster.rapid Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
/* 
  This example demonstrates the different ways of using property sets in our models. Resources
  are based on data structures defined in data models. Data structures contain properties which may
  need adapting to the requirements of the API in question. Property Sets are one aspect of what
  we call 'realization modeling'. They may be used used to add constraints to specific properties
  or to exclude properties that we don't need entirely from our resources. There are four kinds 
  of Property Set each of which has its own syntax:
  
  1. Constraining: used to add constraints to the specified properties.
  2. Excluding: used to exclude specific properties from the resource. 
  3. Combination: used to both add constraints and exclude properties.
  4. Itemized: used to specify a precise list of properties that will be included in the resource.
  
  Property sets may be specified at the resource level and/or at the the request and/or response level.
  Property sets specified at the request/response level override those specified at resource level.
  Only one property set may be defined at any of these levels.
  
  We can also use target properties as a way of specifying property sets in resources.
  For more information on this method of specifying property sets please see example project: 
  'Reference Embedding with Property Subsets'.
  
  Comments are used in the code to draw attention to the feature being demonstrated in this example.
*/
rapidModel TaxBlaster

	resourceAPI TaxBlasterInterface baseURI "http://taxblaster.com/api"

		objectResource TaxFilingObject type TaxFiling
			URI taxfilings/{id}
				required templateParam id property filingID
			mediaTypes
				application/json
			method GET getTaxFiling
				request
				response TaxFilingObject statusCode 200
				response statusCode 400

		objectResource PersonObject type Person
			URI people/{id}
				required templateParam id property taxpayerID

			// =============================
			// Resource level property sets:
			// =============================
			// Comment/uncomment each of the following examples by highlighting the lines and pressing 
			// Ctrl + '/'. Watch the diagram to see what effect this has on the data being exposed by 
			// the resource.
			
			// --------------------------
			// 1. Constraining: 
			//    In this example we turn taxpayerID into a SSN by adding a regex constraint.
			// --------------------------
//			with all properties including
//				taxpayerID
//					matching regex r"(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}"

			// --------------------------
			// 2. Excluding: 
			//    Explicitly exclude properties we don't want in this context. Useful when 
			//    data structures contain numerous properties which would simply add noise 
			//    to the API. 
			// --------------------------
//			with all properties excluding
//				otherNames

			// --------------------------
			// 3. Combination:
			//    Uses both an including and excluding clause.
			// --------------------------
//			with all properties
//			including
//				taxpayerID
//					matching regex r"(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}"
//			excluding
//				otherNames

			// --------------------------
			// 4. Itemized:
			//    State precisely which properties you want. May use constraints here too.
			// --------------------------
//			with only properties
//				taxpayerID
//					matching regex r"(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}"
//				lastName
//				firstName

			mediaTypes
				application/json
			method GET getPersonObject
				request
				// All four types of property set may be used at the level of requests and responses.
				// Here we add an itemised set to a response to limit the data coming back from this
				// response in particular. 
				response with type Person statusCode 200
//					with only properties
//						taxpayerID
//						firstName
//						lastName
				response statusCode 400
			method PUT putPersonObject
				// Here we add an excluding set to the request so that we only get properties 
				// we care about in the context of this application.
				request with type Person
//					with all properties excluding
//						otherNames
				response statusCode 200
				response statusCode 400

	/** Supporting data types for the TaxBlaster API */
	dataModel TaxBlasterDataModel
		/** A tax filing record for a given user, in a given tax jurisdiction, in a 
		    specified tax year. */
		structure TaxFiling
			/** A unique, system-assigned identifier for the tax filing. */
			filingID : string
			/** Reference to the person who owns this filing. */
			taxpayer : reference to Person
			/** Country, province, state or local tax authority where this is being filed. 
			    */
			jurisdiction : string
			/** Tax year */
			year : gYear
			/** Period within the year, if any */
			period : int
			/** Currency code */
			currency : string
			/** Total income reported on tax filing. */
			grossIncome : decimal
			/** Net tax liability */
			taxLiability : decimal

		/** A TaxBlaster user. */
		structure Person
			/** A unique, system-assigned identifier for the user. */
			taxpayerID : string
			/** Legal family name. */
			lastName : string
			/** Legal first name. */
			firstName : string
			/** Address for this person. */
			address : as reference to Address
			/** Names previously used **/
			otherNames : string*
			
		/** An address for a TaxBlaster user */	
		structure Address
			/** First line of address. */
			firstLine : string
			/** Second line of address. */
			secondLine: string
			/** Town or city. */
			city : string
			/** State, county or province. */
			state : string
			/** Zip or postal code. */
			postalCode : string
			/** Country. */
			country : string
		




© 2015 - 2024 Weber Informatics LLC | Privacy Policy