sperant-api 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 870356b1e113b4da8ab850d488569b39b1d8ba1ef626d66d71b365abfd582935
4
- data.tar.gz: ff69f45c39a84969c6fbbe740a10c0b5256aeb89f8342f93d7b1c84eb74b3c39
3
+ metadata.gz: c254887c9d318140a66af53ffb6f073815d62b62aed1aed3798796eb487a10a4
4
+ data.tar.gz: c0233f7fca76222908805bd3a743df578a7fd1b694efdfea8ebd041d49667087
5
5
  SHA512:
6
- metadata.gz: 84410faecd8b3829e4ddd6475cd55341caafd32b8936a91433be2d96acbcd0851c862b2601ea9ed2dbfa9cb4a1d99ebb8eacbd89c3beff8f6a4436c7057711c6
7
- data.tar.gz: fe670ebde1bef5c54286c40c4da34cb6ba35a3c35f69e949c92d5eebbb53a9339aafe9a05c3ec77e02bdecfa6858feb6ab8dabe64ee6f58779e247617c9b8fa0
6
+ metadata.gz: 1678919c944c5a593ee8377b7574752a2da21a6ba08ba2cdaf057df5333530e80aeb0286c222a839d6cd56a875299b16a6e506f3f592cce4a189c22701a03edf
7
+ data.tar.gz: 7e62119e77a6c5de14c7ffa0b654b5126a0248629897aa172de5a775747a118f9a82d8c42a7c789f623309e5101953ff08144334266d206825e5601071dd77bf
data/README.md CHANGED
@@ -83,6 +83,48 @@ client = SperantApi::Client.new
83
83
  client.projects.list(q: "Prados")
84
84
  ```
85
85
 
86
+ ## Endpoints disponibles
87
+
88
+ Resumen de qué hace cada endpoint para encontrarlos rápido:
89
+
90
+ <details>
91
+ <summary><strong>Proyectos</strong> — listar y obtener un proyecto por ID</summary>
92
+
93
+ | Método | Descripción |
94
+ |--------|-------------|
95
+ | `client.projects.list` | Lista proyectos (paginado). Filtros: `code`, `q`, `page`. |
96
+ | `client.projects.find(id)` | Obtiene un proyecto por su ID. |
97
+
98
+ <pre>GET /v3/projects
99
+ GET /v3/projects/:id</pre>
100
+ </details>
101
+
102
+ <details>
103
+ <summary><strong>Clientes</strong> — listar y obtener un cliente por ID</summary>
104
+
105
+ | Método | Descripción |
106
+ |--------|-------------|
107
+ | `client.clients.list` | Lista clientes (paginado). Filtros: `q` (documento/email/celular), `page`. |
108
+ | `client.clients.find(id)` | Obtiene un cliente por su ID. |
109
+
110
+ <pre>GET /v3/clients
111
+ GET /v3/clients/:id</pre>
112
+ </details>
113
+
114
+ <details>
115
+ <summary><strong>Unidades</strong> — listar y obtener una unidad por ID (dentro de un proyecto)</summary>
116
+
117
+ | Método | Descripción |
118
+ |--------|-------------|
119
+ | `client.units.list(project_id:)` | Lista unidades de un proyecto (paginado). Filtros: `block_id`, `commercial_status_id`, `page`. |
120
+ | `client.units.find(project_id:, id:)` | Obtiene una unidad por ID dentro del proyecto indicado. |
121
+
122
+ <pre>GET /v3/projects/:project_id/units
123
+ GET /v3/projects/:project_id/units/:id</pre>
124
+ </details>
125
+
126
+ ---
127
+
86
128
  ## Uso básico
87
129
 
88
130
  ### Listar proyectos
@@ -103,6 +145,12 @@ response = client.projects.list(code: "PRADOS")
103
145
  response = client.projects.list(page: 2)
104
146
  ```
105
147
 
148
+ ### Obtener un proyecto por ID
149
+
150
+ ```ruby
151
+ project = client.projects.find(456) # Hash con los datos del proyecto
152
+ ```
153
+
106
154
  ### Listar clientes
107
155
 
108
156
  ```ruby
@@ -111,6 +159,12 @@ response = client.clients.list(q: "+51999...") # filtrar por documento, email o
111
159
  response = client.clients.list(page: 1)
112
160
  ```
113
161
 
162
+ ### Obtener un cliente por ID
163
+
164
+ ```ruby
165
+ client_data = client.clients.find(123) # Hash con los datos del cliente
166
+ ```
167
+
114
168
  ### Listar unidades de un proyecto
115
169
 
116
170
  ```ruby
@@ -123,6 +177,12 @@ response = client.units.list(
123
177
  )
124
178
  ```
125
179
 
180
+ ### Obtener una unidad por ID
181
+
182
+ ```ruby
183
+ unit = client.units.find(project_id: 7, id: 42) # Hash con los datos de la unidad
184
+ ```
185
+
126
186
  ## Respuesta paginada
127
187
 
128
188
  Los métodos `list` devuelven un objeto `SperantApi::Response::Paginated` con:
@@ -25,6 +25,14 @@ module SperantApi
25
25
  build_paginated_response(raw)
26
26
  end
27
27
 
28
+ # Realiza GET al path y devuelve el cuerpo de la respuesta (hash parseado).
29
+ # @param path [String, Array<String>] Segmentos del path (se unen con +/+).
30
+ # @return [Hash] Respuesta cruda de la API (suele incluir +data+ para un recurso).
31
+ def get_one(path)
32
+ path = Array(path).join("/")
33
+ connection.get(path)
34
+ end
35
+
28
36
  def build_paginated_response(raw)
29
37
  Response::Paginated.new(
30
38
  data: raw["data"] || [],
@@ -17,6 +17,18 @@ module SperantApi
17
17
  query = { q: q, page: page }.compact
18
18
  get_list(Constants::PATH_CLIENTS, query)
19
19
  end
20
+
21
+ # Obtiene un cliente por ID.
22
+ #
23
+ # @param id [Integer, String] ID del cliente.
24
+ # @return [Hash] Datos del cliente (contenido de +data+ en la respuesta de la API).
25
+ #
26
+ # @example
27
+ # client_data = client.clients.find(123)
28
+ def find(id)
29
+ raw = get_one([Constants::PATH_CLIENTS, id])
30
+ raw["data"] || raw
31
+ end
20
32
  end
21
33
  end
22
34
  end
@@ -18,6 +18,18 @@ module SperantApi
18
18
  query = { code: code, q: q, page: page }.compact
19
19
  get_list(Constants::PATH_PROJECTS, query)
20
20
  end
21
+
22
+ # Obtiene un proyecto por ID.
23
+ #
24
+ # @param id [Integer, String] ID del proyecto.
25
+ # @return [Hash] Datos del proyecto (contenido de +data+ en la respuesta de la API).
26
+ #
27
+ # @example
28
+ # project_data = client.projects.find(456)
29
+ def find(id)
30
+ raw = get_one([Constants::PATH_PROJECTS, id])
31
+ raw["data"] || raw
32
+ end
21
33
  end
22
34
  end
23
35
  end
@@ -20,6 +20,20 @@ module SperantApi
20
20
  query = { block_id: block_id, commercial_status_id: commercial_status_id, page: page }.compact
21
21
  get_list(path, query)
22
22
  end
23
+
24
+ # Obtiene una unidad por ID dentro de un proyecto.
25
+ #
26
+ # @param project_id [Integer] ID del proyecto.
27
+ # @param id [Integer, String] ID de la unidad.
28
+ # @return [Hash] Datos de la unidad (contenido de +data+ en la respuesta de la API).
29
+ #
30
+ # @example
31
+ # unit_data = client.units.find(project_id: 7, id: 42)
32
+ def find(project_id:, id:)
33
+ path = [Constants::PATH_PROJECTS, project_id, Constants::PATH_UNITS, id]
34
+ raw = get_one(path)
35
+ raw["data"] || raw
36
+ end
23
37
  end
24
38
  end
25
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SperantApi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sperant-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Palacios