DialService represents a service for managing dials.
| 80 | |
| 81 | // DialService represents a service for managing dials. |
| 82 | type DialService interface { |
| 83 | // Retrieves a single dial by ID along with associated memberships. Only |
| 84 | // the dial owner & members can see a dial. Returns ENOTFOUND if dial does |
| 85 | // not exist or user does not have permission to view it. |
| 86 | FindDialByID(ctx context.Context, id int) (*Dial, error) |
| 87 | |
| 88 | // Retrieves a list of dials based on a filter. Only returns dials that |
| 89 | // the user owns or is a member of. Also returns a count of total matching |
| 90 | // dials which may different from the number of returned dials if the |
| 91 | // "Limit" field is set. |
| 92 | FindDials(ctx context.Context, filter DialFilter) ([]*Dial, int, error) |
| 93 | |
| 94 | // Creates a new dial and assigns the current user as the owner. |
| 95 | // The owner will automatically be added as a member of the new dial. |
| 96 | CreateDial(ctx context.Context, dial *Dial) error |
| 97 | |
| 98 | // Updates an existing dial by ID. Only the dial owner can update a dial. |
| 99 | // Returns the new dial state even if there was an error during update. |
| 100 | // |
| 101 | // Returns ENOTFOUND if dial does not exist. Returns EUNAUTHORIZED if user |
| 102 | // is not the dial owner. |
| 103 | UpdateDial(ctx context.Context, id int, upd DialUpdate) (*Dial, error) |
| 104 | |
| 105 | // Permanently removes a dial by ID. Only the dial owner may delete a dial. |
| 106 | // Returns ENOTFOUND if dial does not exist. Returns EUNAUTHORIZED if user |
| 107 | // is not the dial owner. |
| 108 | DeleteDial(ctx context.Context, id int) error |
| 109 | |
| 110 | // Sets the value of the user's membership in a dial. This works the same |
| 111 | // as calling UpdateDialMembership() although it doesn't require that the |
| 112 | // user know their membership ID. Only the dial ID. |
| 113 | // |
| 114 | // Returns ENOTFOUND if the membership does not exist. |
| 115 | SetDialMembershipValue(ctx context.Context, dialID, value int) error |
| 116 | |
| 117 | // AverageDialValueReport returns a report of the average dial value across |
| 118 | // all dials that the user is a member of. Average values are computed |
| 119 | // between start & end time and are slotted into given intervals. The |
| 120 | // minimum interval size is one minute. |
| 121 | AverageDialValueReport(ctx context.Context, start, end time.Time, interval time.Duration) (*DialValueReport, error) |
| 122 | } |
| 123 | |
| 124 | // DialFilter represents a filter used by FindDials(). |
| 125 | type DialFilter struct { |
no outgoing calls
no test coverage detected