(id string)
| 653 | ) |
| 654 | |
| 655 | func (s *Store) getByID(id string) (*FrequencyPlan, error) { |
| 656 | descriptions, err := s.descriptions() |
| 657 | if err != nil { |
| 658 | return nil, errReadList.WithCause(err) |
| 659 | } |
| 660 | description, ok := descriptions.get(id) |
| 661 | if !ok { |
| 662 | return nil, errNotFound.WithAttributes("id", id) |
| 663 | } |
| 664 | proto, err := description.proto(s.Fetcher) |
| 665 | if err != nil { |
| 666 | return nil, errRead.WithCause(err).WithAttributes("id", id) |
| 667 | } |
| 668 | if description.BaseID != "" { |
| 669 | base, ok := descriptions.get(description.BaseID) |
| 670 | if !ok { |
| 671 | return nil, errReadBase.WithCause(errNotFound.WithAttributes("id", description.BaseID)).WithAttributes( |
| 672 | "id", description.ID, |
| 673 | "base_id", description.BaseID, |
| 674 | ) |
| 675 | } |
| 676 | var baseProto FrequencyPlan |
| 677 | baseProto, err = base.proto(s.Fetcher) |
| 678 | if err != nil { |
| 679 | return nil, errReadBase.WithCause(err).WithAttributes( |
| 680 | "id", description.ID, |
| 681 | "base_id", description.BaseID, |
| 682 | ) |
| 683 | } |
| 684 | proto = baseProto.Extend(proto) |
| 685 | } |
| 686 | if err := proto.Validate(); err != nil { |
| 687 | return nil, errInvalid.WithCause(err) |
| 688 | } |
| 689 | return &proto, nil |
| 690 | } |
| 691 | |
| 692 | // GetByID retrieves the frequency plan that has the given ID. |
| 693 | func (s *Store) GetByID(id string) (*FrequencyPlan, error) { |
no test coverage detected