Download the PHP package ajtarragona/censat-client without Composer

On this page you can find all versions of the php package ajtarragona/censat-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package censat-client

Censat Client for Laravel

Client d'accés a la API Rest de l'aplicació CENSAT de l'Ajuntament de Tarragona

Table of Contents generated with DocToc

Instalació

Configuració

Pots configurar el paquet a través de l'arxiu .env de l'aplicació. Aquests son els parámetres disponibles :

Per a l'accés via API

Si definim un token, es farà servir aquest per totes les peticions. Si no, se'n crearà un de nou per cada petició a partir de l'usuari i password. És recomanable doncs definir un token ja que es faran la meitat de crides. Censat genera tokens amb una expiració d'un any a través del mètode Login de la seva Api.

Per a l'accés via Base de Dades

Alternativament, pots publicar l'arxiu de configuració del paquet amb la comanda:

Això copiarà esl arxiu a censat-api.php i censat-database.php a la carpeta config.

Via API

Un cop configurat, el paquet està a punt per fer-se servir. Ho pots fer de les següents maneres:

A través d'una Facade:

Per Laravel < 5.6, cal registrar l'alias de la Facade a l'arxiu config/app.php :

Vía Injecció de dependències: Als teus controlladors, helpers, model:

Vía funció helper:

Funcions

Definició de censos i entitats

censuses()

Returns all censuses. Objects of class Census

census($short_name)

Returns a census given its name.

censusEntities($short_name)

Returns a census entities given the census name. Objects of class Entity

entities()

Returns all entities.

entity($short_name)

Returns an entity given its name.

entityFields($short_name)

Returns an entity fields given the entity name. Objects of class Field

entityField($entity_name, $field_name)

Returns a single entity field given the entity name and the field name.

entityGridFields($short_name, $grid_name)

Returns the fields of an entity grid, given the entity name and the grid name.

Accedint a les instàncies (Crear, modificar i consultar)

instances($census_name, $entity_name, $options=[])

Returns all instances in a given census and entity. Objects of class Instance

Options:

Fields:

Podem especificar quins camps volem que se'ns retornis amb una llista dels noms, separats per coma.

Tenim l'alias basefields que ens retornarà els camps base (id, dates, versio...)

Però a més, podem navegar pel model de dades mitjançant notació punt. Per exemple si volem que ens retorni l'id d'un camp de relació, podem fer:

En el cas de grids o camps múltiples (relacions, integracions, selects) tenim els accessors especials:

I la gràcia és que tot plegat es pot concatenar:

Formatadors Sobre cada camp, podem aplicar formatadors separant-los amb el caràcter |. Aquests s'aplicaran al valor retornat. Per exemple podem fer que ens retorni un valor de text en majúscules:

Es poden concaternar varios formatadors que s'aplicaran en ordre.

Aquests son els disponibles:

search($census_name, $entity_name, $filters, $options=[])

Search instances in a given census and entity.

Filters:

Must be an array of filters or filtergroups: A filter must be a key-value array with following attributes:

A filtergroup must be a key-value array with following attributes:

Options:
instancesTree($census_name, $entity_name, $field_name, $options=[])

Returns the whole instances tree given a census name, an entity name and the field name that establishes the instances parenthood hyerarchy.

Options:
instance($census_name, $entity_name, $id, $options=[])

Returns a single instance given a census name, an entity name and the instance id.

Options:
getInstanceField($census_name, $entity_name, $id, $field_name)

Get an instance field given a census and entity, the instance id and the field name.

createInstance($census_name, $entity_name, $fields)

Create an instance in a given census and entity. Returns the created instance or an exception.

deleteInstance($census_name, $entity_name, $id, $hard=false)

Delete and instance given a census and entity and the instance id. By default it is a soft delete. Hard delete can be forced setting the parameter hardto true. Returns true or an Exception

updateInstance($census_name, $entity_name, $id, $fields)

Update an instance given a census and entity and the instance id. Fields must be a key-value array with the field names and its values. Returns the updated instance or an Exception.

updateInstanceField($census_name, $entity_name, $id, $field_name, $value)

Update an instance single field. Returns the updated instance or an Exception.

clearInstanceField($census_name, $entity_name, $id, $field_name)

Clears (sets to null) an instance field. Returns the updated instance or an Exception.

addInstanceFieldItem($census_name, $entity_name, $id, $field_name, $value)

Add an item to an instance field, given its value. It is useful for multiple fields (relations, selects, integrations or grids). Returns the updated instance or an Exception.

removeInstanceFieldItem($census_name, $entity_name, $id, $field_name, $item_id)

Removes an instance field item, given its id It is useful for multiple fields (relations, selects, integrations or grids). Returns the updated instance or an Exception.

Graelles (Grids)

getInstanceGridItems($census_name, $entity_name, $id, $grid_name)

Returns the items of an instance grid.

getInstanceGridItem($census_name, $entity_name, $id, $grid_name, $grid_item_id)

Returns an item of an instance grid, given its id.

addInstanceGridItem($census_name, $entity_name, $id, $grid_name, $values=[])

Add an item to an instance grid, given its value. Returns the updated instance an Exception.

updateInstanceGridItem($census_name, $entity_name, $id, $grid_name, $grid_item_id, $values=[])

Updates an instance grid item. Returns the updated instance an Exception.

removeInstanceGridItem($census_name, $entity_name, $id, $grid_name, $grid_item_id)

Removes an instance grid item, given its id. Returns the updated instance an Exception.

Entitats relacionades

addInstanceRelatedItem($census_name, $entity_name, $id, $field_name, $item_id)

Add an item to an instance relation field, given its id. Returns the updated instance an Exception.

removeInstanceRelatedItem($census_name, $entity_name, $id, $field_name, $item_id)

Remove an item from an instance relation field, given its id. Returns the updated instance an Exception.

Attachments (documents)

getAttachment($attachment_id)

Returns an attachment info given its Censat ID

getAttachmentContent($attachment_id)

Returns an attachment content (encoded in base64) given its Censat ID

downloadAttachment($attachment_id)

Downloads (streams the file through the response) an attachment given its Censat ID

Trees Feature

getTrees($options=[])

Retorna tots els arbres

getTree($tree_id, $options=[])

Retorna un arbre passant el seu ID o short_name

getTreeNodes($tree_id, $options=[])

Retorna els nodes d'un arbre

Options:
getNode($tree_id, $node_id, $options=[])

Retorna un node d'un arbre passant els seus IDs.

getNodeChildren($tree_id, $node_id, $options=[])

Retorna els fills d'un node

getNodeParent($tree_id, $node_id, $options=[])

Retorna el pare d'un node

getNodeAncestors($tree_id, $node_id, $options=[])

Retorna els ancestres d'un node

getNodeDescendants($tree_id, $node_id, $options=[])

Retorna els descendents d'un node

getNodeSiblings($tree_id, $node_id, $direction=null, $options=[])

Retorna els germans d'un node. Es pot especificar si volem només els següents (next) o anteriors (prev)

Classes

Els diferents mètodes de consulta retornen objectes de diferents classes. A través d'aquestes classes també podem fer crides a diferents mètodes.

Census

entity($entity_name)

Returns an entity in the census given its name

entities()

Returns all the census entities

Entity

fields()

Returns all the entity fields

field($short_name)

Returns an entity field given its name

relatedEntity($short_name)

Returns the related entity given an entity-relation field name

forCensus($census_name)

Locates the entity in the given census. The following methods only work if this has been called previously

all($options=[])

Returns all the instances of the entity

get($id, $options=[])

Returns an instance of the entity given its id. See instances method available options.

search($filters, $options=[])

Search instances in the entity. See search method for filter options.

tree( $short_name, $options=[])

Returns the whole instances tree in the entity given the field name that establishes the instances parenthood hyerarchy.

create( $options=[])

Creates an instance in the entity. See createInstance method

Field

settings()

Returns the field settings

options()

For select field types, returns the select options.

gridFields()

For grid field types, returns the grid fields.

relatedEntity()

For entity-relation field types, returns the related entity

Instance

entity()

Return the instance entity

census()

Return the instance census

update($fields)

Updates the instance given an array of fields. See createInstance method

get($field_name)

Gets the value of given field

set($field_name, $value)

Sets the value of given field

add($field_name, $value)

Adds a value to a given field. Useful for multiple fields and grids.

clear($field_name)

Clears (sets to null) the given field.

remove($field_name, $item_id)

Removes an item from a given field. Useful for multiple fields and grids.

delete()

Soft deletes the instance

destroy()

Destroys the instance

TreeNode

parent($options=[])

Retorna el no de pare

siblings($direction=null, $options=[])

Retorna els germams

descendants($options=[])

Retorna els descendents

ancestors($options=[])

Retorna els ancestres

children($options=[])

Retorna els fills directes

Vía Base de Dades (Eloquent )

Alternativament podem fer servir Eloquent per accedir als models del censat, sempre i quant tinguem accés a la base de dades.

Simplement cal definir els nostres models extenent el model base CensatEntityModel.

Estem treballant amb models Eloquent, per la qual cosa tenim disponible tota la seva funcionalitat: QueryBuilder, Relacions, Scopes, Mutators, etc.

Documentació d'Eloquent

IMPORTANT! Per ara només és aconsellable fer servir aquest mètode per consulta. Realitzar modificacions (create, update, delete) directament podria donar generar inconsistència a les dades: no s'auditen els canvis, no s'actualitza caché...

Camps data

Si la nostra entitat té algun camp de tipus Data, podem indicar-ho aprofitant el mutator de Laravel $dates.

Integracions i Mapes

Els camps de tipus Integració o de tipus Mapa son objectes json internament, per la qual cosa ho podem indicar aprofitant el casting d'atributs de Laravel:

Relacions

Si una entitat té algun camp de Relació, ho podem indicar a partir dels atributs $simple_relations i $multiple_relations, indicant el nom del camp i el nom de la classe que modela la entitat relacionada.

Definint els camps de relació d'aquesta manera aquests automàticament esdevenen relacions Eloquent al model. Podem fer coses com aquestes, per exemple:

Aquests exemples d'Eloquent son extensibles als camps Select i Grids que veurem tot seguit.

Selects

Si una entitat té algun camp de tipus Select, ho podem indicar a partir dels atributs $simple_selects i $multiple_selects, indicant el nom del camp i el nom de la classe que modela el select.

Aquesta classe del Select haurà d'extendre la classe CensatSelectModel, indicant el nom de la entitat i el nom del camp.

Grids

Si una entitat té alguna graella, ho podem indicar a partir de l'atribut $grids, indicant el nom de la graella i el nom de la classe que la modela.

Aquesta classe del Grid haurà d'extendre la classe CensatGridModel, indicant el nom de la entitat i el nom de la graella.


All versions of censat-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|^8.0
laravel/framework Version >=6.0
guzzlehttp/guzzle Version >=6.3
kalnoy/nestedset Version >=5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ajtarragona/censat-client contains the following files

Loading the files please wait ....