npm package: @jobgoal/sdk-angular-gcloud
Description: JobGoal Angular SDK for interacting with GCloud Firebase Functions APIs (recruitment and account)
Author: JobGoal
Latest version: 0.3.1

# @jobgoal/sdk-angular-gcloud

Angular SDK for JobGoal GCloud Firebase Functions APIs

## Installation

```bash
npm install @jobgoal/sdk-angular-gcloud
```

## Features

- **recruitment Module**: Manage vacancies, candidates, and applications
- **Account Module**: Manage organizations
- Full TypeScript support with type definitions
- RxJS observables for reactive programming
- Angular dependency injection integration

## Usage

### Setup

Configure the API base URLs in your Angular module:

```typescript
import { ApplicationConfig } from '@angular/core';
import { provideHttpClient } from '@angular/common/http';
import { RECRUITMENT_API_BASE_URL, IDENTITY_API_BASE_URL } from '@jobgoal/sdk-angular-gcloud';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(),
    { provide: RECRUITMENT_API_BASE_URL, useValue: 'https://your-recruitment-api.com' },
    { provide: IDENTITY_API_BASE_URL, useValue: 'https://your-identity-api.com' }
  ]
};
```

Or in a standalone component:

```typescript
import { Component } from '@angular/core';
import { provideHttpClient } from '@angular/common/http';
import { recruitment_API_BASE_URL } from '@jobgoal/sdk-angular-gcloud/recruitment';

@Component({
  // ...
  providers: [
    provideHttpClient(),
    { provide: recruitment_API_BASE_URL, useValue: 'https://your-recruitment-api.com' }
  ]
})
export class MyComponent {}
```

**Note:** `provideHttpClient()` is required for the SDK to make HTTP requests. Make sure to include it in your application configuration or component providers.

### Using the recruitment Module

#### Vacancy Management

```typescript
import { Component, inject, OnInit } from '@angular/core';
import { VacancyApi } from '@jobgoal/sdk-angular-gcloud/recruitment';

@Component({
  selector: 'app-vacancy-manager',
  template: `...`
})
export class VacancyManagerComponent implements OnInit {
  private vacancyApi = inject(VacancyApi);

  ngOnInit() {
    // List vacancies for an organization
    this.vacancyApi.list({
      owner_id: 'org-123',
      statuses: ['OPEN', 'DRAFT']
    }).subscribe(response => {
      // response.vacancies contains the list
    });

    // Read a specific vacancy
    this.vacancyApi.read({ vacancy_id: 'vac-456' })
      .subscribe(vacancy => {
        // Use vacancy data
      });
  }

  createVacancy() {
    this.vacancyApi.create({
      owner_id: 'org-123',
      title: 'Delivery Driver',
      description: 'Looking for reliable delivery driver',
      employer_name: 'ACME Corp',
      employment_address: {
        street: '123 Main St',
        city: 'Amsterdam',
        postal_code: '1012AB',
        country: 'NL'
      },
      employment_type: 'PART_TIME',
      minimum_age: 18,
      contact_person: {
        name: 'John Doe',
        email: 'john@acme.com',
        phone: '+31612345678'
      }
    }).subscribe(response => {
      // response.id contains the new vacancy ID
    });
  }

  updateVacancy(vacancyId: string) {
    this.vacancyApi.patch({
      id: vacancyId,
      title: 'Senior Delivery Driver',
      status: 'OPEN'
    }).subscribe(() => {
      // Vacancy updated
    });
  }

  deleteVacancy(vacancyId: string) {
    this.vacancyApi.delete({ vacancy_id: vacancyId })
      .subscribe(() => {
        // Vacancy deleted
      });
  }
}
```

#### Candidate Management

```typescript
import { Component, inject } from '@angular/core';
import { CandidateApi } from '@jobgoal/sdk-angular-gcloud/recruitment';

@Component({
  selector: 'app-candidate-manager',
  template: `...`
})
export class CandidateManagerComponent {
  private candidateApi = inject(CandidateApi);

  loadCandidate(candidateId: string) {
    this.candidateApi.read(candidateId)
      .subscribe(candidate => {
        // Use candidate data
      });
  }

  createCandidate() {
    this.candidateApi.create({
      full_name: 'Jane Smith',
      birth_date: '1995-06-15',
      personal_email_address: 'jane.smith@example.com',
      mobile_phone_number: '+31612345678',
      residential_address: {
        street: '456 Oak St',
        city: 'Rotterdam',
        postal_code: '3011AB',
        country: 'NL'
      },
      language_levels: {
        'nl': 'C2',
        'en': 'B2'
      }
    }).subscribe(response => {
      // response.id contains the new candidate ID
    });
  }

  updateCandidate(candidateId: string) {
    this.candidateApi.patch({
      id: candidateId,
      mobile_phone_number: '+31698765432'
    }).subscribe(() => {
      // Candidate updated
    });
  }
}
```

#### Application Management

```typescript
import { Component, inject } from '@angular/core';
import { ApplicationApi } from '@jobgoal/sdk-angular-gcloud/recruitment';

@Component({
  selector: 'app-application-manager',
  template: `...`
})
export class ApplicationManagerComponent {
  private applicationApi = inject(ApplicationApi);

  listApplicationsForCandidate(candidateId: string) {
    this.applicationApi.list({ candidate_id: candidateId })
      .subscribe(response => {
        // response.applications contains the list
      });
  }

  listApplicationsForVacancy(vacancyId: string) {
    this.applicationApi.list({ vacancy_id: vacancyId })
      .subscribe(response => {
        // response.applications contains the list
      });
  }

  applyToVacancy(candidateId: string, vacancyId: string) {
    this.applicationApi.apply({
      candidate_id: candidateId,
      vacancy_id: vacancyId
    }).subscribe(response => {
      // response.id contains the application ID
    });
  }

  updateApplicationStatus(applicationId: string) {
    this.applicationApi.updateStatus({
      id: applicationId,
      status: 'HIRED'
    }).subscribe(() => {
      // Application status updated
    });
  }
}
```

### Using the Account Module

```typescript
import { Component, inject } from '@angular/core';
import { OrganizationApiService } from '@jobgoal/sdk-angular-gcloud/account';

@Component({
  selector: 'app-organization-manager',
  template: `...`
})
export class OrganizationManagerComponent {
  private orgApi = inject(OrganizationApiService);

  readOrganization(orgId: string) {
    this.orgApi.read(orgId)
      .subscribe(org => {
        // Use organization data
      });
  }

  createOrganization() {
    this.orgApi.create({
      organization_name: 'ACME Corp',
      organization_kvk: '12345678',
      entity_legal_form: 'BV',
      address: {
        street: '123 Business Ave',
        city: 'Amsterdam',
        postal_code: '1012AB',
        country: 'NL'
      },
      correspondence_email: 'info@acme.com'
    }).subscribe(response => {
      // response.id contains the new organization ID
    });
  }

  updateOrganization(orgId: string) {
    this.orgApi.patch({
      id: orgId,
      organization_name: 'ACME Corporation',
      correspondence_email: 'contact@acme.com'
    }).subscribe(() => {
      // Organization updated
    });
  }

  deleteOrganization(orgId: string) {
    this.orgApi.delete(orgId)
      .subscribe(() => {
        // Organization deleted
      });
  }
}
```

## Module Exports

### recruitment Module
```typescript
import {
  VacancyApi,
  CandidateApi,
  ApplicationApi,
  recruitment_API_BASE_URL,
  // ... types
} from '@jobgoal/sdk-angular-gcloud/recruitment';
```

### Account Module
```typescript
import {
  OrganizationApiService,
  IDENTITY_API_BASE_URL,
  // ... types
} from '@jobgoal/sdk-angular-gcloud/account';
```

## API Response Structure

All API responses follow this structure:

```typescript
interface ApiResponse<T> {
  data: T;
  problems: Problem[];
  status_code: number;
}

interface Problem {
  severity: string;
  message: string;
  details: Problem[];
}
```

The SDK services automatically extract the `data` field from responses.

## Requirements

- Angular 17.0.0 or 18.0.0+
- RxJS 7.5.0+

## Development

Build the library:

```bash
npm install
npm run build
```

Pack for local testing:

```bash
npm run pack
```

## Contributing

See [VERSIONING.md](./VERSIONING.md) for information about:
- Version management and semantic versioning
- Automated deployment workflows
- Change detection and publishing triggers
- Manual version bumps and releases

## License

MIT