Documentation
¶
Overview ¶
Package urlarg provides utilities for parsing Basecamp URLs into IDs. This allows users to paste URLs from the browser as command arguments.
Index ¶
- func ExtractCommentWithProject(arg string) (id, projectID string, err error)
- func ExtractID(arg string) (string, error)
- func ExtractIDs(args []string) ([]string, error)
- func ExtractProjectID(arg string) string
- func ExtractWithProject(arg string) (recordingID, projectID string, err error)
- func IsURL(input string) bool
- type OccurrenceError
- type Parsed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractCommentWithProject ¶
ExtractCommentWithProject extracts a comment ID and project ID from an argument. For URLs with a fragment (e.g., #__recording_789), returns the comment ID. For URLs without a fragment, returns the recording ID (same as ExtractWithProject). Returns (commentOrRecordingID, projectID).
func ExtractID ¶
ExtractID extracts the primary ID from an argument. If the argument is a Basecamp URL, extracts the recording ID. Otherwise, returns the argument as-is (assumed to be an ID).
func ExtractIDs ¶
ExtractIDs extracts IDs from multiple arguments, handling URLs and comma-separated values (e.g. "123,456,789"). One occurrence URL refuses them all, before the caller acts on any.
func ExtractProjectID ¶
ExtractProjectID extracts the project (bucket) ID from an argument. If the argument is a Basecamp URL, extracts the bucket ID. Otherwise, returns the argument as-is.
func ExtractWithProject ¶
ExtractWithProject extracts both the recording ID and project ID from an argument. Returns (recordingID, projectID). If projectID is empty, it wasn't in the URL.
Types ¶
type OccurrenceError ¶ added in v0.18.0
type OccurrenceError struct {
EntryID string
Date string
URL string // the occurrence's URL, without any comment fragment
}
OccurrenceError reports a URL that names one occurrence of a recurring schedule entry. The occurrence is a recording of its own and the API cannot change it, so the extractors refuse the URL rather than return the entry's ID, which would act on the whole series.
func (*OccurrenceError) Error ¶ added in v0.18.0
func (e *OccurrenceError) Error() string
type Parsed ¶
type Parsed struct {
AccountID string
ProjectID string // BucketID in Basecamp terminology
Type string // e.g., "todos", "messages", "cards"
RecordingID string
CampfireID string // parent campfire ID for chat-line URLs (chats/{campfireId}/lines/{lineId})
PingID string // the Ping (a Circle bucket) named by circles/{pingId} and circles/{pingId}@{lineId} URLs
CommentID string
IsCollection bool // URL points to a list of items, not an individual resource
OccurrenceDate string // date from schedule_entries/{id}/occurrences/{date} URLs
}
Parsed represents components extracted from a Basecamp URL.
func Parse ¶
Parse extracts IDs from a Basecamp URL. Returns nil if the input is not a valid Basecamp URL, if its path goes past the item it names to another one Parse does not model, or if the ID it ends in is a person's or an embed's, so that callers refuse it rather than act on the wrong recording.
Supported URL patterns:
- https://3.basecamp.com/{account}/buckets/{bucket}/{type}/{id}
- https://3.basecamp.com/{account}/buckets/{bucket}/{type}/{id}#__recording_{comment}
- https://3.basecamp.com/{account}/buckets/{bucket}/card_tables/cards/{id}
- https://3.basecamp.com/{account}/buckets/{bucket}/chats/{id}@{lineId}
- https://3.basecamp.com/{account}/circles/{ping}
- https://3.basecamp.com/{account}/circles/{ping}@{lineId}
- https://3.basecamp.com/{account}/my/sidebar/circles/{ping}, with or without @{lineId}
- https://3.basecamp.com/{account}/buckets/{bucket}/schedule_entries/{id}/occurrences/{date}
- https://3.basecamp.com/{account}/buckets/{bucket}/vaults/{folder}/documents/{id}, and the other children bc3 nests under folders, to-do lists, and questionnaires
- any of these followed by segments with no ID, such as /edit, and an upload followed by /download/{filename} or a version's /download/{filename} or /representations/{key}
- https://3.basecamp.com/{account}/projects/{project}