File Coverage

blib/lib/SignalWire/Agents/REST/Namespaces/Registry.pm
Criterion Covered Total %
statement 28 56 50.0
branch 0 8 0.0
condition n/a
subroutine 12 24 50.0
pod 0 12 0.0
total 40 100 40.0


line stmt bran cond sub pod time code
1             package SignalWire::Agents::REST::Namespaces::Registry;
2 4     4   28 use strict;
  4         8  
  4         172  
3 4     4   22 use warnings;
  4         38  
  4         235  
4 4     4   22 use Moo;
  4         8  
  4         23  
5              
6             # --- RegistryBrands ---
7             package SignalWire::Agents::REST::Namespaces::Registry::Brands;
8 4     4   1676 use Moo;
  4         9  
  4         32  
9             extends 'SignalWire::Agents::REST::Namespaces::Base';
10              
11             sub list {
12 0     0 0 0 my ($self, %params) = @_;
13 0 0       0 my $p = %params ? \%params : undef;
14 0         0 return $self->_http->get($self->_base_path, params => $p);
15             }
16              
17             sub create {
18 0     0 0 0 my ($self, %kwargs) = @_;
19 0         0 return $self->_http->post($self->_base_path, body => \%kwargs);
20             }
21              
22             sub get {
23 0     0 0 0 my ($self, $brand_id) = @_;
24 0         0 return $self->_http->get($self->_path($brand_id));
25             }
26              
27             sub list_campaigns {
28 0     0 0 0 my ($self, $brand_id, %params) = @_;
29 0 0       0 my $p = %params ? \%params : undef;
30 0         0 return $self->_http->get($self->_path($brand_id, 'campaigns'), params => $p);
31             }
32              
33             sub create_campaign {
34 0     0 0 0 my ($self, $brand_id, %kwargs) = @_;
35 0         0 return $self->_http->post($self->_path($brand_id, 'campaigns'), body => \%kwargs);
36             }
37              
38             # --- RegistryCampaigns ---
39             package SignalWire::Agents::REST::Namespaces::Registry::Campaigns;
40 4     4   3328 use Moo;
  4         9  
  4         79  
41             extends 'SignalWire::Agents::REST::Namespaces::Base';
42              
43             sub get {
44 0     0 0 0 my ($self, $campaign_id) = @_;
45 0         0 return $self->_http->get($self->_path($campaign_id));
46             }
47              
48             sub update {
49 0     0 0 0 my ($self, $campaign_id, %kwargs) = @_;
50 0         0 return $self->_http->put($self->_path($campaign_id), body => \%kwargs);
51             }
52              
53             sub list_numbers {
54 0     0 0 0 my ($self, $campaign_id, %params) = @_;
55 0 0       0 my $p = %params ? \%params : undef;
56 0         0 return $self->_http->get($self->_path($campaign_id, 'numbers'), params => $p);
57             }
58              
59             sub list_orders {
60 0     0 0 0 my ($self, $campaign_id, %params) = @_;
61 0 0       0 my $p = %params ? \%params : undef;
62 0         0 return $self->_http->get($self->_path($campaign_id, 'orders'), params => $p);
63             }
64              
65             sub create_order {
66 0     0 0 0 my ($self, $campaign_id, %kwargs) = @_;
67 0         0 return $self->_http->post($self->_path($campaign_id, 'orders'), body => \%kwargs);
68             }
69              
70             # --- RegistryOrders ---
71             package SignalWire::Agents::REST::Namespaces::Registry::Orders;
72 4     4   3065 use Moo;
  4         8  
  4         18  
73             extends 'SignalWire::Agents::REST::Namespaces::Base';
74              
75             sub get {
76 0     0 0 0 my ($self, $order_id) = @_;
77 0         0 return $self->_http->get($self->_path($order_id));
78             }
79              
80             # --- RegistryNumbers ---
81             package SignalWire::Agents::REST::Namespaces::Registry::Numbers;
82 4     4   2121 use Moo;
  4         28  
  4         37  
83             extends 'SignalWire::Agents::REST::Namespaces::Base';
84              
85             sub delete_number {
86 0     0 0 0 my ($self, $number_id) = @_;
87 0         0 return $self->_http->delete_request($self->_path($number_id));
88             }
89              
90             # --- RegistryNamespace ---
91             package SignalWire::Agents::REST::Namespaces::Registry;
92 4     4   1900 use Moo;
  4         9  
  4         16  
93              
94             has '_http' => ( is => 'ro', required => 1 );
95             has 'brands' => ( is => 'lazy' );
96             has 'campaigns' => ( is => 'lazy' );
97             has 'orders' => ( is => 'lazy' );
98             has 'numbers' => ( is => 'lazy' );
99              
100             my $base = '/api/relay/rest/registry/beta';
101              
102 2     2   5074 sub _build_brands { SignalWire::Agents::REST::Namespaces::Registry::Brands->new(_http => $_[0]->_http, _base_path => "$base/brands") }
103 2     2   7135 sub _build_campaigns { SignalWire::Agents::REST::Namespaces::Registry::Campaigns->new(_http => $_[0]->_http, _base_path => "$base/campaigns") }
104 1     1   3574 sub _build_orders { SignalWire::Agents::REST::Namespaces::Registry::Orders->new(_http => $_[0]->_http, _base_path => "$base/orders") }
105 1     1   2862 sub _build_numbers { SignalWire::Agents::REST::Namespaces::Registry::Numbers->new(_http => $_[0]->_http, _base_path => "$base/numbers") }
106              
107             1;